When does a web browser send If-Modified-Since?

I serve dynamically generated recent.rss via python's flank and, of course, this way it always goes through 200 OK . I was about to fix this by setting the Expires header for a week to the future and checking if the If-Modified-Since browser was sent.

If this is the case (after comparing the dates), I would just do return nothing, 304 instead of return response , but according to Firebug and request.environ my browser just does not send If-Modified-Since for this resource.

I know that I can just save the data to a file and serve it as a real static file using a web server, but I might need static files through WSGI, and even if I didn’t want to know why this does not work.

Thanks for any help.

+4
source share
1 answer

RFC 2616 HTTP / 1.1 has this note in 14.25 If-Modified -Since :

When processing the If-Modified-Since header field, some servers will use the exact date comparison function, not less than the function, to decide whether to send 304 (Not Changed). To get the best results when sending the If-Modified-Since header field to check the cache, clients are advised to use the exact date string obtained in the previous Last-Modified header field whenever possible.

This means that you must send the Last-Modified header when you expect / want the client to send If-Modified-Since .

+11
source

All Articles