SysAdmin

How to enable Leverage Browser Caching in website with .htaccess

JJ
Jobin Joseph · Founder and CEO
·Published 28 June 2014·1 min read

Issue

Environment

Resolution

Add the following entry in your .htaccess file.

# Leverage Browser Caching START
ExpiresActive On 
ExpiresByType image/jpg "access 7 days"
ExpiresByType image/jpeg "access 7 days"
ExpiresByType image/gif "access 7 days"
ExpiresByType image/png "access 7 days"
ExpiresByType text/css "access 7 days"
ExpiresByType text/html "access 2 days"
ExpiresByType application/pdf "access 7 days"
ExpiresByType text/x-javascript "access 7 days"
ExpiresByType application/x-shockwave-flash "access 7 days"
ExpiresByType image/x-icon "access 7 days"
ExpiresDefault "access 7 days" 
# Leverage Browser Caching END
Now go to gtmetrix.com and test your site. You should see 100% gzip compression.

Read : How to enable gzip compression on my website

Jobin Joseph
Jobin Joseph, Founder and CEO
5x AWS Certified, ISO 27001:2022 Lead Implementer, 17+ years building cloud infrastructure for regulated industries.
About Jobin →

Reading this because your AWS bill or uptime is a problem?

30 minutes, direct with the founder, no sales pitch: one specific recommendation for your AWS workload.

Book a free 30-minute review
30 min Free Consultation →