Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
Thread: set expire header
01-21-2012, 06:59 AM #1
set expire header
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');
01-21-2012, 07:38 AM #2
- Join Date
- Jan 2012
- Thanked 6 Times in 6 Posts
Users who have thanked 12k for this post:
01-22-2012, 01:19 AM #3
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, 05:30 AM #4
- Join Date
- Sep 2005
- Sydney, Australia
- Thanked 701 Times in 690 Posts
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.
Users who have thanked felgall for this post:
01-22-2012, 06:47 AM #5
Fantastic info ----- yep i'm on shared hosting. Never knew about that and nothing I read even remotely mentioned that.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
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