Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no 'Last-Modified' HTTP header -> however cached?

From a browser perspective,

What occur if a component (image, script, stylesheet...) is served without a Last-Modified HTTP header field...

Is it however cached by the browser even if it won't be able to perform a validity check(If-Modified-Since) in future, due to his lack of date/time information?

Eg:

GET /foo.png HTTP/1.1
Host: example.org
--
200 OK
Content-Type: image/png

...

Is foo.png however cached?

--

Would you know any online service to serve my raw HTTP response that I can write myself in order to test what I'm asking ?

Thank you.

like image 482
abernier Avatar asked Mar 29 '11 19:03

abernier


People also ask

Are HTTP headers cached?

Cache-Control is a HTTP cache header that contains a set of parameters to define the browser's caching policies in the client requests and server responses. When a client makes a request to the server, the browser can cache, or store copies of resources for faster access and lower latency.

What happens if you don't set Cache-Control header?

Without the cache control header the browser requests the resource every time it loads a new(?) page.

Why if modified since header line is used in web caching?

The If-Modified-Since HTTP header indicates the time for which a browser first downloaded a resource from the server. This helps determine whether or not the resource has changed since the last time it was accessed.

How do I set Cache-Control HTTP header?

To use cache-control in HTML, you use the meta tag, e.g. The value in the content field is defined as one of the four values below. HTTP 1.1. Allowed values = PUBLIC | PRIVATE | NO-CACHE | NO-STORE.


1 Answers

Generally speaking, responses can be cached unless they explicitly say that they can't (e.g., with cache-control: no-store).

However, most caches will not store responses that don't have something that they can base freshness on, e.g., Cache-Control, Expires, or Last-Modified.

For the complete rules, see: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p6-cache-13#section-2.1

See: http://www.mnot.net/blog/2009/02/24/unintended_caching for an example of how this can surprise some people.

like image 199
Mark Nottingham Avatar answered Sep 23 '22 07:09

Mark Nottingham