Best Leverage Browser Caching Setting for Dynamic Website

Si Thu Phyo
Newbiesbox
Published in
2 min readJul 12, 2016

Setting up leverage browser caching makes your website more faster and it tells the browser to cache some files that are not change often such as logo, css, js, and others. I already wrote about leverage browser caching in this website. But leverage browser caching settings will be different depending to your website types. If your website type is static and no need to change any settings for a month or more, you can set caching access time by month or year. But if your website is dynamic and often change site data, your leverage browser caching setting should be modify. Most of newbies in web development use some plugins for leverage browser caching. It is not a problem if their website is static website. But if their website is dynamic types like as blog, forum and magazine, their leverage browser caching plugins will make them headache. In this article, I will show best leverage browser caching setting for dynamic website. If you are looking for static website optimization, read this article and follow the instruction.

Most of leverage browser caching plugins for CMS set HTTP expires headers time to month, year and day. According to my experience, I use some leverage browser caching plugins for my website and it will make headache. My website generates at least an article per day and visitors traffic is now 20000 to 25000. A problem is occurred when the reader visits to my website, browser only showed outdated articles. Update news and articles are showed when the reader reload the browser. This problem is occurred due to leverage browser caching plugin. So, I adjust and modify leverage browser caching settings. Copy and paste the following code to your .htaccess file and save the file.

## BEGIN Expires Caching by Newbiesbox (Leverage Browser Caching) ##
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 5 seconds”
ExpiresByType image/x-icon “access plus 604800 seconds”
ExpiresByType image/jpeg “access plus 604800 seconds”
ExpiresByType image/png “access plus 604800 seconds”
ExpiresByType image/gif “access plus 604800 seconds”
ExpiresByType application/x-shockwave-flash “access plus 604800 seconds”
ExpiresByType text/css “access plus 604800 seconds”
ExpiresByType text/javascript “access plus 604800 seconds”
ExpiresByType application/javascript “access plus 604800 seconds”
ExpiresByType application/x-javascript “access plus 604800 seconds”
ExpiresByType text/html “access plus 600 seconds”
ExpiresByType application/xhtml+xml “access plus 600 seconds”
</ifModule>
## END Expires Caching by Newbiesbox (Leverage Browser Caching) ##

In this setting, I set expires time of html,xhtml,xml to 600 seconds. You can set your custom expires times. Now, I optimized this settings for dynamic websites such as blog, magazine ,forum, news, and others. If you are using leverage browser caching plugins and face the problem like me, this code will fix your problem. Cheers…

Read More Article at newbiesbox.com.

--

--

Si Thu Phyo
Newbiesbox

I’m a WordPress developer and trainer of Web Development Class at Myanmar Tech Wave. Founder of newbiesbox.com and love in writing and playing Kyokushin karate.