';

How do I turn on/off browser cache for images, CSS and JS?


EXPERIENCING PROBLEMS WITH OUR SERVICES? RUN A DIAGNOSE FIRST TO SAVE YOURS AND OUR TIME

Added: 19.01.2017 11:30:16     Last updated: 19.01.2017 12:18:02

Browser cache is used to hold images, CSS and JS files locally on your computer so the files does not download from the server each time you reload the website in your browser. If any of the files are updated on the server, the server will tell the browser about the change and the browser will download a fresh version of the file.

Default caching time is normally set to 604800 seconds (7 days) on our servers.

It is also possible to get fresh content from the server if there are changes made on the files and they are not showing by using the following combinations on the keyboard:
Windows: Ctrl + F5
Mac/Apple: Command + R
Linux: F5

It is possible to change the settings using a .htaccess file:

## EXPIRES CACHING ##
< IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
< /ifmodule>
## EXPIRES CACHING ##


Another example if you want to disable browser cache in visitors browsers. Then you can add this in .htaccess file:

## EXPIRES CACHING ##
< IfModule mod_expires.c>
ExpiresActive Off
< /ifmodule>
## EXPIRES CACHING ##

The downside to disable browser cache is that all the files are loaded directly from server each time the visitor reload the website is that it will use more resources and cause website to be slower.