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

查看:430
本文介绍了检查浏览器的缓存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标头。究竟如何做到这一点取决于你所使用的Web服务器。

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:

阿帕奇 - <一个href=\"http://httpd.apache.org/docs/2.0/mod/mod_expires.html\">http://httpd.apache.org/docs/2.0/mod/mod_expires.html

IIS - <一个href=\"http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0fc16fe7-be45-4033-a5aa-d7fda3c993ff.mspx?mfr=true\">http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0fc16fe7-be45-4033-a5aa-d7fda3c993ff.mspx?mfr=true

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

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