There are some files which are always same from server side. Leverage browsing cache means we save some files like stylesheets, JavaScript files and images into browser for later use. That way the user’s browser will download less data while navigating through your pages, which will improve the loading speed of your website.
This gives a better and optimized experience to user. While loading 1 page to other the same files do not load again and again. So browser uses them without downloading from server again and again.
How to Leverage browser caching
To enable browser caching for Images, CSS and JS, add those lines to your website’s .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 6 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 6 month"
ExpiresByType text/javascript "access 6 month"
ExpiresByType application/x-javascript "access 6 month"
ExpiresByType application/javascript "access 6 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType video/mp4 "access 1 year"
ExpiresDefault "access 6 month"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(css)$">
Header set Cache-Control "max-age=15780000, public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "max-age=15780000, public"
</filesMatch>
<filesMatch "\.(html)$">
Header set Cache-Control "max-age=15780000, public"
</filesMatch>
</ifModule>
# END Cache-Control Headers
Note: This code is useful only for Apache servers for other type of servers please consult your hosting provider.
ABOUT LEVERAGE BROWSER CACHING
Leverage Browser Caching means storing static files of a website in visitor browser. And then retrieving them from browser quickly instead again from server. Actually it uses to speed up each page of a website.
HOW LEVERAGE BROWSER CACHING WORKS?
When you visit a web page, your browser downloads all content of the particular page as well as common static files like css and js files. And when you visit other page of same website, your browser downloads them again. But if you have enabled Leverage Browser Caching, then all statics files will serve from your browser instead server. Now when you will visit any page of the particular website, it will only download unique contains of the page and static files will serve from your browser. in this way, it speed up each page of a website.
How beneficial Leverage browser caching is
Primary benefit is speeding up website because static files will be served from your browser. It also saves bandwidth of website server and decrease load of server. Simply it decreases HTTP requests.
Page load times can be significantly improved by asking visitors to save and reuse the files included in your website.
- Reduces page load times for repeat visitors
- Particularly effective on websites where users regularly re-visit the same areas of the website
- Benefit-cost ratio: high
- Access needed
- it saves internet data of website visitor.
We also provide all type of Website optimization services. Please check our website speed optimization service. Also these all services are part of our WordPress maintenance service.