View Full Version : set expire header
01-21-2012, 07:59 AM
Yeh, I'm pretty sure this is easy for everyone here but it's new to me.
I have this notice from my page and I want to follow the instruction
"The following cacheable resources have a short freshness lifetime.
Specify an expiration at least one week in the future for the following resources:"
etc it lists all the images on the page
I'm not sure what is the best / correct way to do this
Do I have to set the expire header like this at the top of my page
and change it on a weekly basis? (can't be right)
header('Expires: Fri, 01 Jan 2012 05:00:00 GMT');
Help much appreciated
You should just use a htaccess file.
01-22-2012, 02:19 AM
Thanks for the link
I'm still in need of help so if anybody can throw more light on this subject that would be appreciated.
After a lot of reading i'm still pretty clueless.
Does this look right? What should I set the Expire Year to? One year from now ie 2013 so it will cache -- is that right?
What happens if page content eventually changes --- which it will --- I can't rename the page because it's an index page --- how does the Last_Modified header work?
Like I said -- still pretty clueless:-(
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
# 2 HOURS
Header set Cache-Control "max-age=7200, must-revalidate"
01-22-2012, 06:30 AM
One thing to note is that if your site is using shared hosting then the hosting provider is not going to allow you to adjust the expires header - they will have set it to a fixed value for the entire server so as to provide the most efficient setup for the typical sites that they host.
You will only have access to set it if you have VPS or dedicated hosting. In that case you are probably best off setting it up in the appropriate Apache configuration files so as to not need to override the values in individual .htaccess files all over the place.
01-22-2012, 07:47 AM
One thing to note is that if your site is using shared hosting then the hosting provider is not going to allow you to adjust the expires header
Fantastic info ----- yep i'm on shared hosting. Never knew about that and nothing I read even remotely mentioned that.
So I guess I should just leave it as is and not mess with anything.
I think i'll ask my hosting provider about expire headers anyway just to find out for myself what they have to say on it.
Using Firefox I can see this as my response headers and there is no mention of Expires, Cache-Control or Last-Modified ---- non of which I understand anyway but I thought these should be set.
Date: Sun, 22 Jan 2012 00:57:40 GMT
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.