Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Chrome browser is not sending if-modified-since header to server

Chrome browser is not sending if-modified-since header to server

Problem

I have these headers being sent to the client by the server:

Cache-Control:private
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Sun, 27 Nov 2011 11:10:38 GMT
ETag:"12341234"
Set-Cookie:connect.sid=e1u...7o; path=/; expires=Sun, 27 Nov 2011 11:40:38 GMT; httpOnly
Transfer-Encoding:chunked
last-modified:Sat, 26 Nov 2011 21:42:45 GMT

I want the client to validate that the file hasn't changed on the server and send a "200" if it has otherwise a "304".

Firefox sends:

if-modified-since: Sat, 26 Nov 2011 21:42:45 GMT
if-none-match: "12341234"

Why isn't the chrome sending the same on a refresh of the page? I'm after the behavior that .Net has running:

context.Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate)
Problem courtesy of: Asken

Solution

In my experience you need more than just the "Private" Cache-Control header. You need either "Max-Age" or "Expires" to force Chrome to revalidate content with the server.

Remember that revalidation will only start after these time values have elapsed, so they may need to be set to a small value.

Solution courtesy of: Andy McCluggage

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Chrome browser is not sending if-modified-since header to server

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×