I found out that some browser (probably Safari; I'm waiting for the answer) cache my Javascript without being told to.
The script gets loaded simply by
<script src="some-name.js"></script>
The server (my embedded Jetty) sends the following headers:
Date: Fri, 03 Mar 2017 00:17:04 GMT
Server: ...
Vary: origin, accept-encoding, authorization, x-role
Date: Fri, 03 Mar 2017 00:17:04 GMT
Content-Type: application/javascript; charset=utf-8
Content-Encoding: gzip
ETag: "0e5dd67b500a018f0996bc417e032083"
The ETag computations seems to be right. The Date is repeated twice (no idea why), but IMHO no date matters at all, as there's no expiration. I expect the browser to send If-None-Match:"0e5..." whenever the page is needed, am I wrong?
As I'm using HTTPS exclusively, so I don't care about proxy caches. I see that loading all files individually and always checking their freshness is very inefficient, but that's another story. So I thought, I'd need no cache control for now.
For now I wonder if a browser is allowed to cache a page (and for how long) without an explicit permission and without checking its freshness? How can I disable it? (*)
(*) I do want caching, but only after checking the ETag.
Cache-control: no-cacheno-cacheis obviously wrong.no-cache is obviously wrong? It's written in the specifications that when it's honoured (which is true for all major browsers) it'll make sure a response is not cached.