Forum Moderators: phranque

Message Too Old, No Replies

Help setting Last_Modified server response headers

this is still a good idea, right?

         

nancyb

5:05 pm on Jan 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just moved from a host where Last_Modified date was the default.

I'm now hosted the same place as this board and wonder if anyone who is also hosted there has set the server response headers in the default httpd.conf file to include Last_Modified date. Tried getting help from tech support, but not had any success getting an answer so far .....

This should be a simple thing, right, with just a line or two of code and it should go in httpd.conf, right?

Downloaded a copy of my default httpd.conf file, but can't determine where the code should go, even if I knew what it should be.

I'm scared to change anything in httpd since I've blown up my site in the past doing something I didn't understand.

TIA

jdMorgan

5:21 am on Jan 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, I've searched the documentation, and come up empty-handed as to why one host would provide Last-Modified headers while another one wouldn't.

Last-Modified headers are NOT provided for dynamically-generated content (mainly because the content is generated, and therefore last-modified, only after it is requested). But I'm assuming you didn't change anything, just moved hosts.

However, this may tie in with mod_expires in some undocumented way. So if you want to "risk it", just add ExpiresActive on in the config for your site and see if that changes anything.

"Crashing" your server is not the worst thing in the world, as long as it's only for a short time. If it *is* a major concern, you could always set up a 'test' subdomain on the same account, and test in a small, controlled environment. I've always learned best by staring at error logs containing lines that say 500-Server Error, myself... ;)

Jim

nancyb

6:47 pm on Jan 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right, no dynamic pages, just moved. I've been at a number of different hosts and this seems to be a default some places and not others. Never thought about it till last year (or whenever) when GG suggested it would be good to set the "if_modified" which I understood was the term used on his side of things, as opposed to on our side.

Just received a note from tech support saying they searched Google for this setting. This would seem to indicate they aren't too familiar with this, but it was nice they actually searched for the answer (not my experience at most hosts). This is what they suggest I add:
Header append Cache-Control "public"
ExpiresActive On
ExpiresDefault "modification plus 1 day"

Good suggestion to set up a sub domain and watch 500s swim by :-)

Thanks Jim - as always you are my Apache saviour ;)

jdMorgan

8:12 pm on Feb 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nancy,

It just so happens that I set up an account on the same host this morning, and observed the same lack of a Last-Modified header that you did.

I prefer to expire files relative to when they were last accessed by the client, rather than relative to when I last modified them -- this evens out the server load. This way, files are only reloaded by client browsers when they are 'old' compared to when that client last loaded them, and not to when I last updated them. This avoids the problem of having a client reload infrequently-updated files from the server every time they are requested.

The code I'm using looks like this:


# Set up Cache Control headers
ExpiresActive On
# Default - Set http header to expire everything 1 week from last access, set must-revalidate.
ExpiresDefault A604800
Header append Cache-Control: "must-revalidate"
# Expire error pages, test pages, and frequently-updated files after 1 second, set no-cache header.
<FilesMatch "^(test[0-9]?¦404¦410¦403[a-z]?)\.html$">
ExpiresDefault A1
Header unset Cache-Control:
Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>
# Index and events pages, and robots.txt file expire after two hours.
<FilesMatch "^index\.html">
ExpiresDefault A7200
</FilesMatch>
<FilesMatch "^(events¦calendar)\.html$">
ExpiresDefault A7200
</FilesMatch>
<FilesMatch "^robots\.txt$">
ExpiresDefault A7200
</FilesMatch>

and I can verify that after adding this code, the Last-Modified headers are now present and correct.

This code may or may not be right for your site; It's only intended as an example. Note that I use both header-unset and header-append, rather than header-set. I had some problems with header-set in the past, so I just do it this way.

Jim