How to change browser caching on your site

How to set leverage browser caching cpanel

In your .htaccess file you can paste the following directives at the top of the file:


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 text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"


By using this code, our main static files like images, CSS, JS, PDF’s etc. will be cached in order to produce faster loading times in the future.

You can see in the above code that there are time periods like “1 year” or “1 month”. These are associated with file types, as an example the above code states that a css file should be cached for a month. If you want to change that and say you want them only cached for a year you would simply replace “1 month” with “1 year”. The values above are pretty optimized for most webpages and blogs.

<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif|html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=29030400"

you have set all files (PDF, image, webpage, etc) to expire in peoples’ browsers after 1 year.

It is easy to leverage browser caching in TYPO3 and other CMS with this tutorial.

That’s it for leveraging browser caching with your .htaccess file!

I hope it will help you lot.. Best Luck 🙂

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya


One thought on “How to change browser caching on your site

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s