具体缓存JavaScript和CSS文件 [英] Caching specific Javascript and CSS files

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

问题描述

我如何可以缓存一些特定的JavaScript和放大器; CSS文件。我发现建议从这个网站把它放到我的的.htaccess 文件

How can I cache a few specific JavaScript & CSS files. I found advice from this site to put this in my .htaccess file

AddOutputFilter DEFLATE css js
ExpiresActive On
ExpiresByType application/x-javascript A2592000

但它是不完全的。什么是的.htaccess ?我如何创建它,在哪里存储它,在我的Web根文件夹?

But it is incomplete. What is .htaccess and how do I create it, where to store it, in my web root folder?

什么是下面的语句的含义是:

What is the meaning of the following statements:

AddOutputFilter DEFLATE css js
ExpiresActive On
ExpiresByType application/x-javascript A2592000

我不想缓存所有我的JavaScript和放大器; CSS文件,而只是几个特定文件,这永远不会改变。

I dont want to cache all my Javascript & CSS files rather just a few specific files which will never change.

我怎样才能做到这一点?

How can I do this?

推荐答案

您可以配置IIS通过扩展缓存特定文件。例如:

You can configure IIS to cache specific files by extension. For example:

选择您的CSS / JS文件所在的文件夹,然后单击输出缓存。

Select the folder where your css/js files reside and then click on Output Caching.

然后添加要缓存的文件扩展名:

Then add the file extensions that you want to cache:

我不认为你可以指定在每个文件的基础缓存哪些除非你写一个HTTP 处理程序模块添加各自独立文件中相应的标题,但是从IIS这是怎么了已经完成了。

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.

然后,你可以验证你正在使用萤火虫/小提琴手或您选择的工具304的响应。

Then you can verify that you are getting 304 responses using firebug / fiddler or your tool of choice.

我希望这是很有帮助的。

I hope this is helpful.

这篇关于具体缓存JavaScript和CSS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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