How and for how long do browsers store Etags?

I wish to implement ETag based cache-control, and I am wondering how long ETags are stored in a browser and if they can be kept for longer than the current session.

I have the server setting and sending ETags for responses correctly, and I am sending requests from the browser with jQuery.ajax.

The system works correctly, responding with the appropriate 304 response if the Not-Modified header (previous ETag) matches the generated ETag on the server. This all works fine for the current session, however when I close the browser and reopen it, the Not-Modified header is not being sent by jQuery any more.

I am wondering if there are any methods I could use to trigger the default browser behaviour, and send the Not-Modified header for responses (if applicable), without manually setting the header in the ajax request or storing the ETag in localStorage/indexedDb.


An Etag must be accompanied by other tags that tell the browser how long to hold the content

It is important to specify one of Expires or Cache-Control max-age, and one of Last-Modified or ETag, for all cacheable resources. It is redundant to specify both Expires and Cache-Control: max-age, or to specify both Last-Modified and ETag.

So it all depends on the duration you specify with the Expires or max-age tag on how long the browser will hold it

The only purpose of the etag is so that the browser can issue a "if modified" request after the initial expiration period to see if the content has actually changed or gets back a 304 not modified.

Badly managed 304's can cause other problems, like unnecessary and redundant 304 requests:

Need Your Help

Error when trying to convert BufferedImage into int array

java arrays bufferedimage

I am trying to convert my BufferedImage into a integer array, but i am getting the following error: "java.awt.image.DataBufferByte cannot be cast to java.awt.image.DataBufferInt"

or in regular expression

.net regex

I am using this (?<=^.*?;).* expression to parse out user id one by one. It works good because they are separated by ; but fails when it gets to the last person who does not have ; at end of his...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.