如何缓存一些特定的 JavaScript 和 CSS 文件。我从这个网站找到了建议,将其放入我的.htaccess
file
AddOutputFilter DEFLATE css js
ExpiresActive On
ExpiresByType application/x-javascript A2592000
但这是不完整的。什么是.htaccess
以及如何创建它,将其存储在我的网络根文件夹中?
以下陈述的含义是什么:
AddOutputFilter DEFLATE css js
ExpiresActive On
ExpiresByType application/x-javascript A2592000
我不想缓存所有的 Javascript 和 CSS 文件,而只是缓存一些永远不会改变的特定文件。
我怎样才能做到这一点?
您可以将 IIS 配置为按扩展名缓存特定文件。例如:
Select the folder where your css/js files reside and then click on Output Caching.
然后添加要缓存的文件扩展名:
I don't think you can specify which ones to cache on a per file basis unless you write an http handler module to add the appropriate headers for each file independently, but from IIS this is how is done.
然后您可以使用 firebug / fiddler 或您选择的工具验证是否收到 304 响应。
我希望这是有帮助的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)