Looking for a quick solution to implement Leverage Browser Cache in WordPress
Everybody wants his/her website to be brisk and fast loading. It’s a perpetual contest and conquest. Having a dismal website loading speed is as good as having….well no website at all. Custom Website designs have better loading speed than templated using many third party plugins.A simple google search for increasing your WordPress site speed will take you to the world of ‘Leverage Browser Caching’. But hang on! That’s not our world or at least not of so many reluctant and reticent website owners who, still, understand ‘cash’ better than ‘cache’. And there is always a plugin! Right?Wait! Let’s not get ahead of ourselves. Options are An HTML code! in your .htaccess file If this sounds complicated, there are always plugins like W3 Total Cache.
Let’s start by understanding the working of Leverage Browser Caching in WordPress Website Design and understanding (or stealing) about its magic wand which makes web pages to lead faster.
A web browser is in constant communication with a server for retrieval of various resources (i.e. HTML, CSS, images, text etc.) to load a website. ‘Web Cache’ helps web browsers and applications to temporarily store or remember data of visited web pages on local disk. When you visit the web page again, web browser only downloads updated content.
Cool, eh? It is just like remembering the first edition of a book and only reading updated material from 2nd edition. Do you think, reading 2nd edition of a book, now, will take time?By following this simple logic, web cache helps to reduce bandwidth usage, load on server etc. So Leverage Browser Caching helps to load web pages faster.How to Leverage Browser Caching
If your web server allows the web browser to store resources of visited web page temporarily on local disk, next time, a user visit to the website will load faster. But the pertinent question here is how to enable this?
To enable Leverage Browser Caching on WordPress, you need to set content expiry dates in HTTP headers. It is done by adding Cache-Control Headers and ETag headers. Cache-Control is about the caching period of a particular file by web browser. Etag is to verify changes between cached and requested resources. We can keep cache resources by setting a specific period in months or years.
Details:If your website is hosted on Apache server (without WordPress plugin), Its a three step procedure to enable Leverage Browser Caching
1) Add Expires Headers
2) Add Cache Control Headers
3) Turn E tags off
You need to edit your WordPress .htaccess file. Copy and paste the following code in .htaccess file and Save the same.
# START EXPIRES CACHING #
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
# END EXPIRES CACHING #
# BEGIN Cache-Control Headers
Header set Cache-Control "public"
Header set Cache-Control "public"
Header set Cache-Control "private"
Header set Cache-Control "private, must-revalidate"
# END Cache-Control Headers
# BEGIN Turn ETags Off
# END Turn ETags Off
Enterprise Web Cloud is a complete website design and digital marketing agency. Engage with us, Impress your customers, and Get more leads. Boost your business GROWTH with Enterprise Web Cloud.
Connect, organize and get things done to keep your IT business safe.