When do cached static files expire if not specified? - caching

In IIS6, I notice that when "Enable content expiration" is not enabled, no cache-related or expiration headers are sent with the response. Yet static content, such as css files are properly returning 304 statuses on subsequent visits.
When does this content expire if nothing is specified? Is it browser dependent?

If Content Expiration isn't specified in IIS then the caching of website content will be controlled or affected by external factors such as your browser's settings, upstream proxies or content caching servers between the end user and your web server. These are often factors out side of your control.
Setting content expiration in IIS should force these 3rd parties to honour these caching settings and expire content at the correct time.

Related

Server control of browser cache expiration timeout

We have an online learning management system hosted in IIS. A common problem is learners have to clear browser cache to resume an online course that had minor updates in recent history.
The LMS is classic ASP, the server is Windows 2012, IIS 7.
What I am hoping is that IIS has a setting to serve files with a timeout on the cache expiration that the client browser will honor.
Any help appreciated.
You could use "httpExpires" attribute which specifies a date and time that the content should expire, You need to add an HTTP "Expires" header to the response.
To configure a cache expiration date for a Web site or application you could follow the below steps:
Open Internet Information Services (IIS) Manager.
In the Connections pane, go to the site for which you want to
disable caching.
From the feature view, select HTTP Response Headers.
In the HTTP Response Headers pane, click Set Common Headers... in the
Actions pane.
In the Set Common HTTP Response Headers dialog box, check the box to
expire Web content, select the option to expire after a specific
interval or at a specific time, and then click OK.
You could also refer below article for more detail information:
Client Cache
Regards,
Jalpa

Google Chrome's caching mechanism of static resources varies from other browsers. Is it right?

Setup:
I used nginx server. I experimented with two different sets of header configuration.
1. Expires header only.
2. Expires and Last Modified header
I had the done the following in all the browsers,
Clear the cache.Access the page (or Hard reload). Now , all the resources are freshly downloaded. The page downloads only one JS file.
Do a soft reload. (Cmd + R)
When the soft reload is done,
Case 1:Expires header only
1.Chrome (v55) serves from disk/memory cache with Status 200.It does not fetch resource from the server.
2.Firefox (v51) sends a request and downloads the resource each time with Status 200. When the resource has only one expires header, firefox and other browsers always downloads the resource.
Case 2: Expires and Last Modified header
1.Chrome again serves from disk/memory cache with Status 200. It does not fetch resource from the server.
2.Firefox and Other browsers always sends a 'If-modified-since' header to the server, depending on the header, the server sends either 200 and the resource or 304 Not modified.
The problem with other browsers approach is that , they always send a request for a resource to check it's freshness. Let's say there are 40 static resources, each time i hit a reload the browser will send a request.
This causes increase usage of bandwidth, number of requests to the server.
Which approach is good?
P.S. In chrome ,when u have only 'Last Modified header', it sends a request for 304 Not Modified. But with expires and Last modified, it always serves from cache.

Conditional GET Request and Expiry Header testing with Firebug-NET

I'm using Firebug's NET feature to measure the performance of our application. I'm a bit confused the way it is displaying the timeline. We have enabled Expiry header for all static files(it is 30 days from the current date). Now even if the resource is available in cache, it still makes a conditional GET (that is what I think). Ideally there shouldn't make a connection to the server, but it takes 93ms to create a connection. Please find the image that I've attached.
Can some one please help me to understand this better?
The HTTP response contains a header entry "Etag". ETag is a cache validator tag.
The HTTP Client on seeing this response will always verify with the server if the Content has been updated.
Cache Validator tag has higher preference over other Cache control tags.
If you want content to be served from cache without it being validate on the server side then only keep the Expires header and remove the ETag header.

No expires header sent, content cached, how long until browser makes conditional GET request?

Assume browser default settings, and content is sent without expires headers.
user visits website, browser caches images etc.
user does not close browser, or refresh page.
user continues to surf site normally.
assume the browse doesn't dump the cache for any reason.
The browser will cache images etc as the user surfs, but it's unclear when it will issue a conditional GET request to ask about content freshness (apart from refreshing the page). If this is a browser specific setting, where can I see it's value (for browsers like: safari, IE, FireFox, Chrome).
[edit: yes - I understand that you should always send expires headers. However, this research is aimed at understanding how the browser works with content w/o expires headers.]
From the the HTTP caching spec (section 13.4): Unless specifically constrained by a cache-control (section 14.9) directive, a caching system MAY always store a successful response (see section 13.8) as a cache entry, MAY return it without validation if it is fresh, and MAY return it after successful validation. This means that a user agent is free to do whatever it wants if no cache control header is sent. Most browsers use a combination of user settings and heuristics to determine whether (and how long) to cache in this situation.
HTTP/1.1 defines a selection of caching mechanisms; the expires header is merely one, there is also the cache-control header.
To directly answer your question: for a resource returned with no expires header, you must consider the returned cache-control directives.
HTTP/1.1 defines no caching behaviour for a resource served with no cache-related headers. If a resource is sent with no cache-control or expires headers you must assume the client will make a regular (non-conditional) request the next time the same resources is requested.
Any deviation from this behaviour qualifies the client as being not a fully conformant HTTP client, in which case the question becomes: what behaviour is to be expected from a non-conformant HTTP client? There is no way to answer that.
HTTP caching is complex, to fully understand what a conformant client should do in a given scenario, read and understand the HTTP caching spec.
Unless you send an expires header, most browsers will make a GET request for each subsequent refresh and will either get HTTP 200 OK (it will download the content again) or HTTP 304 Not Modified (and use the data in cache).

How to remove eTag from IIS5 http headers

Running IIS5 (yes, really). I'd like to remove the eTag http header that IIS generates for me. MS has an article on how to sync eTags across the web farm, but not how to remove them ( http://support.microsoft.com/?id=922733 ).
Is there a way to remove eTags?
AFAIK, there's no easy way to remove etag of web resources such as image, css or js files from IIS 5. As each of the etag value regenerates on each subsequent web browser refresh which is unnecessary since there might not be any changes on those web resources.
You might want to try EtagFix, it doesn't remove the etag though but it stabilizes the etag values so they don't change until the web resources are modified.
EtagFix stabilizes the etag that
Internet Information Services (IIS)
generates so that it doesn't change
each time the web server is restarted.
http://www.isapilabs.com/Products/ETagFix/index.htm
Go into Inetmgr and in the website properties, switch to the HTTP Headers tab and add an "ETag" custom HTTP header with no value.
this blog post describes how to completely remove the Etag http header in IIS (iis 6,iis 7 and iis 7.5)
http://lightspeednow.com/blog/2010/05/21/iis-tutorial-how-to-completely-remove-etags-entity-tags-from-iis6-iis7-and-iis7-5/

Resources