Forum Moderators: phranque

Message Too Old, No Replies

Is this server header correct for expiring and age?

server header validation and if modified since

         

danv

4:12 pm on Apr 27, 2006 (gmt 0)

10+ Year Member



When I use a tool ( [web-caching.com...] ) to check some pages of a web site, I seem to get the same type of message.

Is this response OK? Does it have to validate? Thanks.

http://www.example.com/about-us.shtml
Date Thu, 20 Apr 2006 01:45:15 GMT
Expires 5 weeks 6 days ago (Thu, 09 Mar 2006 01:48:28 GMT)
Cache-Control max-age=-3628607
Last-Modified -
ETag -
Content-Length - (actual size: 6107)
Server Apache/1.3.34 (Unix) mod_fastcgi/2.4.2 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a PHP-CGI/0.1b

This object has been deliberately marked stale. It doesn't have a validator present. It doesn't have a Content-Length header present, so it can't be used in a HTTP/1.0 persistent connection. The clock on this Web server appears to be set incorrectly; this can cause problems when calculating freshness.

jdMorgan

6:22 pm on Apr 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this a dynamically-generated site?
Have you added code to set the Expires and Cache-control response headers?

The answers depend on the details.

Jim

danv

8:17 pm on Apr 28, 2006 (gmt 0)

10+ Year Member



This is not a dynamically created web site.
These are static .shtml (SSI) pages (though I do have a word press blog) but this result is from my static home page.

I had to modify the .htaccess file in order to get the expires server header and am hoping that it is correct.

I used the code in .htaccess like this:
### activate mod_expires
ExpiresActive On
### Expire everything else 1 day from when it's last modified
ExpiresDefault "modification plus 1 day"

thanks,

jdMorgan

3:16 am on Apr 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to look into using the XBitHack [httpd.apache.org] directive in Apache mod_include. Otherwise, your server won't send a Last-Modified header for shtml files.

I also recommend using the client-load-time-relative Expires format. That is, expire the document an hour or a day after the client loads it. Otherwise, any document you don't update regularly will have an expiry date in the past (as shown in your example above), and you will lose a good bit of the advantage of client-side and caching-proxy caching.

Jim

danv

1:52 pm on Apr 29, 2006 (gmt 0)

10+ Year Member



Thanks! I'll definately check out xbithack (I hope bluehost supports that)

So I should replace this code:

# Expire everything else 1 day from when it's last modified
ExpiresDefault "modification plus 1 day"

with this code then:
# Expire all docs and images by default to 5 days in future
ExpiresDefault "access plus 1 hour"
# Expire .gif's 1 month from when they're accessed
ExpiresByType image/gif A2592000

If the page is accessed within every hour all the time, will it ever expire then?

4specs

2:00 pm on Apr 29, 2006 (gmt 0)

10+ Year Member



Depends upon how often you change the page. I use a 12 hour refresh on html so a business user will not download the page if they go there twice in a day. I make minor changes every day to 50 pages and that is not significant for most users.

I use a 25 year expire on the images and am careful to change the name or location when the image changes so people get the correct image.

If you use a 1 month expire on the images, after the end of the month from when they first downloaded the image I found that they would do a check to see if it were the same every time they accessed the image and get a 304. The objective is to avoid the 304's. With a 25 year expire there is much less checking, not 100% less but much less.

There are some side issues on the headers if you use mod_gzip where you need to turn off mod_gzip in the image folders and think about how to set headers if you are using includes. But gzipping is another whole topic.

danv

5:29 pm on Apr 29, 2006 (gmt 0)

10+ Year Member



Thanks everyone,

Is it recommended to set both "Last modified" and "expires". Won't "last modified" show that it is 1 month old say, and Google etc. will not bother to re-index it even if it is set to expire in 1 day?

What is the purpose of XbitHack? Is it basically:
1. to set the last modified date before including all my SSI's. So it is faster for the engines?
2. so the "last modified" date is set because SSI and php parsed files don't by default set it?

I checked the file permissions of index.shtml of my home page and it is set to 644. When I changed it to 654, the last modified date is now set! Sound good and secure? -sorry coming from windows world.

(By the - way above, I was asked if it was a dynamically created site - I said no, but I do use SS includes for headers, footers kind of thing)

cheers,

danv

5:33 pm on Apr 29, 2006 (gmt 0)

10+ Year Member



I changed all .shtml files on my site to 654.
Does that sound right?

What about .css and my includes ( .inc) and error404.php that returns a 404 prior to the 404 page?

thanks much!