browser - HTTP caching of transitive resources using IF-Modified-Since - Stack Overflow

Given:index.htmlmain.jsdata.jsonThe initial requests for these files all return the same Last-Modifi

Given:

index.html
main.js
data.json

The initial requests for these files all return the same Last-Modified header value, but no Cache-Control header.

A subsequent request is made...

The request to index.html returns a 304 Not Modified. This is expected as the If-Modified-Since header is sent on the request. Nothing strange here.

However, no request is sent to the server for main.js or any of the resources it fetches (data.json), they are all served from the local cache.

By inference, it would appear that the browser assumes that if the index.html is not modified, then neither is main.js and neither is any of the resources that main.js fetches. Seems odd to me.

Is this behaviour documented anywhere? Am I missing some headers (there weren't any other cache related ones in the responses that I could see.) I am expecting a request to be made to the server for each of the resources (and potentially a 304 back if they haven't changed)

Chrome v132

Given:

index.html
main.js
data.json

The initial requests for these files all return the same Last-Modified header value, but no Cache-Control header.

A subsequent request is made...

The request to index.html returns a 304 Not Modified. This is expected as the If-Modified-Since header is sent on the request. Nothing strange here.

However, no request is sent to the server for main.js or any of the resources it fetches (data.json), they are all served from the local cache.

By inference, it would appear that the browser assumes that if the index.html is not modified, then neither is main.js and neither is any of the resources that main.js fetches. Seems odd to me.

Is this behaviour documented anywhere? Am I missing some headers (there weren't any other cache related ones in the responses that I could see.) I am expecting a request to be made to the server for each of the resources (and potentially a 304 back if they haven't changed)

Chrome v132

Share Improve this question edited Mar 14 at 10:53 Cheetah asked Mar 14 at 10:40 CheetahCheetah 14.5k33 gold badges119 silver badges207 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

If you want a request to be made with each fetch you need to add an explicit Cache-Control: no-cache header to the response. Otherwise, the browser is free to make its own heuristic caching decisions.

Since origin servers do not always provide explicit expiration times, a cache MAY assign a heuristic expiration time when an explicit time is not specified, employing algorithms that use other field values (such as the Last-Modified time) to estimate a plausible expiration time.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744661458a4586485.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信