Google and If-Modified-Since HTTP header


#1

Hello.

I read on Google’s webmaster pages that they recommend your server to have the If-Modified-Since HTTP header enabled in order to save bandwidth.

I opened a support ticket but didn’t get a definitive answer on whether or not it is enabled but that I’d have to test it for myself. I don’t have a clue how to do that.

Anyone have any ideas?

Thanks,

Jennifer


#2

[quote]I read on Google’s webmaster pages that they recommend your server to have the If-Modified-Since HTTP header enabled in order to save bandwidth.
Anyone have any ideas?[/quote]
Probably need to make this clear first. When the client sends a request, it can include the If-Modified-Since header. When the server processes the request, if this header is interpreted and applies to the request, its response will be one of two things - 304 Not modified status or 200 OK with the “modified” resource.

Naturally this doesn’t apply to requests for HTML documents with server-side includes or other forms of generated content such as CGI and PHP. At least I don’t know if Apache passes the If-Modified-Since header on. There is nothing to prevent CGI or PHP from responding with ‘304 Not Modified’ status, though.

Here’s a request-response showing this in action. The first section is the request, which is what Mozilla sent to DreamHost. The second section is the response from DreamHost. And the request was for a static (non-generated) image file.

[code]http://www.openvein.org/images/icons/mozilla_48.png

GET /images/icons/mozilla_48.png HTTP/1.1
Host: www.openvein.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030827
Accept: text/xml,application/xml,application/xhtml xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,/;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Thu, 14 Aug 2003 06:15:52 GMT
If-None-Match: "766931-978-3f3b2918"
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified
Date: Wed, 24 Sep 2003 09:49:55 GMT
Server: Apache/1.3.27 (Unix) DAV/1.0.3 mod_gzip/1.3.26.1a mod_ssl/2.8.10 OpenSSL/0.9.6c PHP/4.2.3
Connection: Keep-Alive
Keep-Alive: timeout=15, max=100
Etag: “766931-978-3f3b2918”

[/code]So you can see this is already implemented on DreamHost’s servers.

This is documented in RC 2616 Hypertext Transfer Protocol – HTTP/1.1

DreamHost’s servers also have mod_gzip installed. If the browser supports it, Apache will compress the content before sending it. This provides additional bandwidth savings for text files. For example my home page is over 2,048 bytes on disk however you’ll see DreamHost compressed that to just 964 bytes before sending it -

[code]http://openvein.org/

GET / HTTP/1.1
Host: openvein.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030827
Accept: text/xml,application/xml,application/xhtml xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,/;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: gallery_upload=
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.x 200 OK
Date: Wed, 24 Sep 2003 10:13:11 GMT
Server: Apache/1.3.27 (Unix) DAV/1.0.3 mod_gzip/1.3.26.1a mod_ssl/2.8.10 OpenSSL/0.9.6c PHP/4.2.3
Last-Modified: Thu, 14 Aug 2003 06:22:30 GMT
Etag: "8212ed-99a-3f3b2aa6"
Accept-Ranges: bytes
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Encoding: gzip
Content-Length: 964
[/code]
:cool: Perl / MySQL / HTML CSS


#3

What program did you use to get the raw headers like that? or did you just do some packet sniffing or something?


Todd Eddy
vrillusions.com


#4

Thanks Atropos7!


#5

It’s an extension, actually. It’s called LiveHTTPHeaders and it is available from mozdev.org - http://livehttpheaders.mozdev.org/

It adds a “Headers” tab to “Page Info” as well as a “Web Development” tool for viewing headers as they are sent and recieved.

:cool: Perl / MySQL / HTML+CSS


#6

Cool I use firebird and checked that site and there’s an extension for it :slight_smile: cool to watch what happens. I guess that’s why I like protocol analyzers as well, just have to figure out the filtering for those since there’s so much traffic :slight_smile:


Todd Eddy
vrillusions.com


#7

Hello
Please tell me where i have put this code.


#8

Nowhere. “If-Modified-Since” is a request header, and as Atropos7 noted ten years ago (wow!), our servers have always responded appropriately to this header.