简体   繁体   English

通过浏览器缓存java脚本

[英]Caching the java script by browser

I'm wandering how does browser caches the javascript files. 我在徘徊浏览器如何缓存javascript文件。 I have utility.js and I use it on multiple pages. 我有utility.js,我在多个页面上使用它。 I know that when I go to www.some_host/page1.html the utility.js is cached for that request. 我知道当我访问www.some_host / page1.html时,实用程序会为该请求缓存utility.js。 What happens if I go to different page www.some_host/page2.html, utility.js is requested again from server or take it from browser cache? 如果我转到不同页面www.some_host / page2.html会发生什么情况,再次从服务器请求utility.js或从浏览器缓存中获取它?

Everything is cached based on its own URI. 一切都基于自己的 URI进行缓存。 It doesn't matter what caused the browser to load it (unless you have something like Vary: referer in the headers, which I've never seen) 导致浏览器加载它的原因并不重要(除非你有类似Vary: referer东西Vary: referer标题中的Vary: referer ,我从未见过)

浏览器通常遵循用于其他资源(页面,图像等)的缓存规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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