Browser caching to optimise page loads
Автор: Rbbrt WebsiteX5.infoHi all, and especially the guys and girls at Incomedia,
I'm in the process of optimizing my website for Google (https://www.schotlandopmaat.nl). I've already added compression and https to the site and am now going through the recommendations Google Pagespeed Insights gives you when you analyse your site.
One of the reccommendations is to work with browser caching. This means that not for every pageload al the elements of the page have to be transfered over the internet.
It would be great if this feature is enabled for the standard WebsiteX5 css and Javascript files, supporting images and elements of the template. But I would also like to be able to give my images (all of them, so also in a text object and in a gallery) a time to live in the browser cache.
Would it be possible to add this to a future version of the program?
Regards,
Robert
Hi Rbbrt.
Thank you for your input. I changed this topic from QUESTION to IDEA, so that we can keep track of it more easily.
As with all the other Idea topics, we will surely keep this under our radar and eventually discuss an implementation, although for which we can give no guarantee.
This could definitely prove of some use for some users, while others might prefer not to activate such an option to avoid the risk of presenting old content to their website's visitors.
Please let us know should you need any more information.
Stefano
Автор
Hi Stefano,
For the benefit of other users, who are looking in this subject, after some investigation and asking for advice with my excellent hosting provider Yourname in the Netherlands, I found, for website which are running on Apache, that adding the following lines to the .htaccess file, enables browser 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 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
Of course the duration of the expiries depends on the website.
I've added them to my .htaccess file, waited a day (to clear intermediate caches) and the only complaints I get from Google's Pagespeed Insights are on external sources, like facebook, twitter and AddThis.
For me, this problem is solved!
Kind regards,
Robert
Hi Robert,
here are some additional strings to the topic. Add to .htaaccess to compress data on server
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can't Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
Автор
Hi Dmitrij,
Yep! That's compression for you. I have it in my .htaccess file as follows :
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
Regards,
Robert
Hi Robert,
thanks for sharing.
A little bit shorter but effectiv.
Have a nice day!