简体   繁体   中英

My javascript could not be cached in browser

I have a website which contains some resource like css and javascript. However some resources are cached in browser while other not.

For example, I checked 2 resource URLs:

The second one looks good, next request is 304 once it's cached in browser, with first request, the request always is 200, I think that it's not cached in client.

Thumbnail for not cached resource

在此处输入图片说明

Thumbnail for caching resource

在此处输入图片说明

Anyone please help to debug and give me the suggestion

I am by no means an expert, but after looking at both response headers, it look like the only notable differences between the two is that you send the first one (the one that isn't cached) using Transfert-encoding: chunked. And it looks like a file can only be cached if content-length is provided.

You should try to specify a length for your document, I think it will do the trick.

Please view these two Links Link1 and Link2 . I hope it will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM