WordPress leverage browser caching rules that are adding into .htaccess file in available in root folder. These rules helps to download and cache the static file content into browser for specific time period. Thus next time when SmartGeekBlog is visited, the major chunk of static files are retrieved from browser cache that are already available. This helps in loading the website faster with minimum file request.
Leveraging via .HTACCESS plugin
Locating the .htaccess file is very simple. If you are using WordPress SEO plugin, then under WordPress SEO go to Tools > Edit Files, you will have Edit the content of your .htaccess add the caching rules and click on update.
Other way of locating .htaccess file in checking in WordPress root folder. If your hosting provided have hidden .htaccess file, then while browsing through File Manager select the checkbox Show Hidden Files. .htacess file will be available in file manager browser.
Note: Rules should be added at the top of any others rules already present in .htaccess file.
Following are the browser caching rules for keep static files in cache memory:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
## EXPIRES CACHING by SmartGeekBlog.com ## <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 text/x-javascript "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresDefault "access 10 days" </IfModule> ## EXPIRES CACHING by SmartGeekBlog ## |
Above rules will now cache all the static files like images, text, CSS, JavaScript file into browser cache memory helps to load website faster when retrieving these files.
You can check the performance of leverage browser caching rules by using Google’s PageSpeed and YSlow! tools.
Browser Caching using WordPress Plugin
W3 Total Cache:
One of the best caching plugin with many features like caching, CDN integration (like MaxCDN) that will speed up your website performance.
Leverage Browser Caching Ninjas:
An extra plugin which is only used for enabling browser caching.
Note and Conclusion:
Make sure that mod_rewrite is enabled in your Apache web server, if not then contact your web server technical team to get it enabled as rewrite module will be needed for completing caching action.