cancel
Showing results for 
Search instead for 
Did you mean: 

I want to cache my jpg files

dunk2007
Newbie
Posts: 4
Thanks: 1
Registered: 30-05-2015

I want to cache my jpg files

PageSpeed /google is unhappy I'm not caching my jpg's and .css files.
I have used Sitemap to tell google about my normal htm files being are good for a day,(<changefreq>daily</changefreq>), how do I do the same for images & css?
What does plusnet support? Do I just put a file in htdocs ? Like htaccess ? to put a http header?
I just want them max-age=86400 e.g. a day.
5 REPLIES
Community Gaffer
Community Gaffer
Posts: 13,224
Thanks: 966
Fixes: 81
Registered: 04-04-2007

Re: I want to cache my jpg files

Try putting something like this into an .htaccess and upload it to your /htdocs folder:
ExpiresActive On
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType image/jpeg "access plus 1 day"
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
ExpiresByType text/css "access plus 1 day"

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

dunk2007
Newbie
Posts: 4
Thanks: 1
Registered: 30-05-2015

Re: I want to cache my jpg files

Thanks bob
I now got this
Leverage browser caching
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
Leverage browser caching for the following cacheable resources:
http://www.google-analytics.com/ga.js (2 hours)
http://www.shastonjazzandswing.co.uk/images/sjs_780x580.jpg (24 hours)
http://www.shastonjazzandswing.co.uk/pictures/pink_babs.jpg (24 hours)
http://www.shastonjazzandswing.co.uk/pictures/yellow_babs.jpg (24 hours)
http://www.shastonjazzandswing.co.uk/sjs_layout_mobile.css (24 hours)
http://www.shastonjazzandswing.co.uk/sjs_layout_monitor.css (24 hours)
http://www.shastonjazzandswing.co.uk/sjs_layout_printer.css (24 hours)
So it's seen the day part, but its still not happy, any ideas?
Community Gaffer
Community Gaffer
Posts: 13,224
Thanks: 966
Fixes: 81
Registered: 04-04-2007

Re: I want to cache my jpg files

Not sure TBH, something like this maybe?

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

Superuser
Superuser
Posts: 9,506
Thanks: 861
Fixes: 53
Registered: 06-04-2007

Re: I want to cache my jpg files

Do the messages simply mean a longer expiry time is recommended (eg 1 week or 1 month)?
David
David
dunk2007
Newbie
Posts: 4
Thanks: 1
Registered: 30-05-2015

Re: I want to cache my jpg files

Thanks, looking again at PageSpeed I think you might be right.
Leverage Browser Caching
This rule triggers when PageSpeed Insights detects that the response from your server does not include caching headers or if the resources are specified to be cached for only a short time.
...
We recommend a minimum cache time of one week and preferably up to one year for static assets, or assets that change infrequently.
...

I changed .htaccess to
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
to test this theory, it removed images from my list, it just complains about my css files.
Thank you both for your advice, I will tweak expires on css, when stable. Thanks again  Smiley