Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Chrome violate the standards in caching?

We noticed Chrome caches files locally and doesn't even send a request to our server to check if there's a newer version of the javascript file.

Example of HTTP response headers for a js file that Google cached:

Accept-Ranges:bytes
Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin:*
Content-Encoding:gzip
Content-Length:5479
Content-Type:application/javascript
Date:Tue, 12 Jan 2016 22:46:07 GMT
ETag:"7d68e1ceb647d11:0"
Last-Modified:Tue, 05 Jan 2016 12:44:25 GMT
Server:Microsoft-IIS/8.5
Vary:Accept-Encoding
x-robots-tag:noindex

Is it valid that Chrome cached the file? There's no Cache-control header or something that declares that the file can be cached locally, it only has ETag and Last-Modified.


BTW

Is there a way (maybe a header) to instruct Chrome to check if the cached file has changed without appending version to the file name? Setting no-cache is not an option since I do want it to be cached, but I want to use the ETag and Last-Modified headers as it should.

like image 341
gdoron is supporting Monica Avatar asked Jan 13 '16 08:01

gdoron is supporting Monica


People also ask

Does Chrome use cache?

Like other web browsers, Google Chrome features a cache that stores files such as images, scripts and video content from websites that you visit over time.

What is caching in Chrome?

They make your online experience easier by saving browsing data. The cache remembers parts of pages, like images, to help them open faster during your next visit.

How do I stop chrome from caching?

When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache. You can then close out of Developer Tools.

Is Google cache Safe?

Google cached pages aren't more or less secure than the non-cache version of the page.


1 Answers

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.

You can always use the must-revalidate directive.

When the must-revalidate directive is present in a response received by a cache, that cache MUST NOT use the entry after it becomes stale to respond to a subsequent request without first revalidating it with the origin server.

Source

like image 142
David King Avatar answered Sep 19 '22 13:09

David King