mod_expires is installed on Apache for this purpose. This enables you to set the server-side lifetime of the cache for your HTML pages, pictures, etc.
- ExpiresActive On
- ExpiresDefault "access plus 30 seconds"
All files have a lifetime of 30 seconds. If the page is reloaded by the user after more than 30 seconds, it is fetched from the server and not from the browser's cache. You can define this even more precisely.
ExpiresActive on ExpiresDefault "now plus 1 hour" ExpiresByType image/gif "access plus 1 hour" ExpiresByType text/html "access plus 4 minutes" ExpiresByType text/plain "access plus 4 minutes"
Here, you can set different values for different files. It is also possible for you to set a cache liftime for only one particular file:
ExpiresActive on ExpiresByType image/gif "access plus 1 minutes"
You can write these commands in your .htaccess file and then load that into the public_html folder. The commands will be active immediately.