MyBB Community Forums

Full Version: Better page speed with expires caching
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Did run a page speed test at Google Pagesteed Insights before and after adding some rules to .htaccess
Got from 79/100 to 84/100, so a little faster loadtime, with more or less no work to make the change.

So if someone want a little faster site, add this rules to your .htaccess 

## EXPIRES CACHING ##

ExpiresActive on
ExpiresByType text/css "access plus 14 days"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"  
ExpiresByType application/javascript "access plus 1 month"  
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/ico "access plus 14 days"
ExpiresByType image/jpg "access plus 14 days"
ExpiresByType image/jpeg "access plus 14 days"
ExpiresByType image/gif "access plus 14 days"
ExpiresByType image/png "access plus 14 days"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType text/html "access plus 14 days"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4  "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType application/x-font-woff  "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/xml  "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/rss+xml   "access plus 1 hour"
ExpiresByType application/atom+xml  "access plus 1 hour"

## EXPIRES CACHING ##

Change in Admin panel. General Settings/Server and optimization settings/ Send No Cache Headers to ON in (otherwise new reply or thread will not show up before cache refresh)
Thanks for this tutorial , i want to double confirm how to do it .
I fine 2 file  htaccess in my root which is htaccess.txt  and  htaccess-nginx.txt , which one should be edit ?
Just copy all the code and paste it below  ?
After setting - Send No Cache Headers to ' Yes ' ?
Unless your hosting is on nginx, you will rename htaccess.txt to just .htaccess. You will then add the rules mentioned to that file.
Nice tutorial for apache, I'll write up something similar for nginx. In the future this should be posted in tutorials.
Nice Tutorial, thanks for sharing
(2017-01-10, 06:57 PM)dragonexpert Wrote: [ -> ]Unless your hosting is on nginx, you will rename htaccess.txt to just .htaccess.  You will then add the rules mentioned to that file.

Thanks for your answer .

May i know what does it different for the expires caching ,
I means storing for long period will be better or short period will be better ?
(  I totally a newbie , i just want to learn somethings new for me )