检查浏览器缓存中的 js 文件 [英] Check browser's cache for a js file

查看:45
本文介绍了检查浏览器缓存中的 js 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查用户缓存中的 javascript 文件.如果他刷新页面或在一段时间后访问该站点.我不需要再次下载那个 js 文件.站点关闭后 js 文件是否会被清理.

How can I check for a javascript file in user's cache. If he refreshed the page or visits the site after sometime. I need not download that js file again. Does the js files get cleaned up after a site is closed.

推荐答案

javascript 文件是否被缓存取决于您的 Web 服务器的设置方式、用户浏览器的设置方式以及您的服务器和服务器之间的任何 HTTP 代理服务器的方式.用户设置.您唯一可以控制的是服务器的设置方式.

Whether a javascript file is cached depends on how your web server is setup, how the users browser is setup and also how any HTTP proxy servers between your server and the user are setup. The only bit you can control is how your server is setup.

如果您想要缓存 javascript 的最佳机会,那么您的服务器需要使用 javascript 文件发送正确的 HTTP 标头.具体如何操作取决于您使用的网络服务器.

If you want the best chance of your javascript being cached then you server needs to be sending the right HTTP headers with the javascript file. Exactly how you do that depends on what web server you are using.

这里有几个可能有帮助的链接:

Here are a couple of links that might help:

Apache - http://httpd.apache.org/docs/2.0/mod/mod_expires.html

IIS - http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0fc16fe7-be45-4033-a5aa-d7fda3c993ff.mspx?mfr=true

这篇关于检查浏览器缓存中的 js 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆