apache - 使用 deflate 在 Apache 中缓存图像、JS 和 CSS

标签 apache .htaccess caching header deflate

我目前正在 Apache 配置中使用 deflate 缓存我的 CSS、JS 和图像。

这是我的代码:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

现在,当我检查标题时,我看到:

Host                www.domain.com
User-Agent          Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept              text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language     en-us,en;q=0.5
Accept-Encoding     gzip, deflate
Accept-Charset      ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection          keep-alive
If-Modified-Since   Fri, 30 Sep 2011 01:05:01 GMT
If-None-Match       "124741af-1c4b9-4ae1136f3f9d0"
Cache-Control       max-age=0

一切看起来都不错,Accept-Encodinggzip, deflate,这是我想要的,但现在我看到Cache-Controlmax-age=0

这会破坏使用 deflate 进行缓存的目的吗?这是否意味着它只缓存 1 天,第二天就不会缓存它或者必须重新加载它?

注意:我的图像很少改变,我的 CSS 和 JS 每周改变一次。

最佳答案

这是两个独立的东西:mod_deflatemod_expires

这里有一些您会感兴趣的文章:

http://developer.yahoo.com/performance/rules.html

LiveHttpHeaders: which cache-control info is right

关于apache - 使用 deflate 在 Apache 中缓存图像、JS 和 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7614107/

相关文章:

ios - 如何避免 iOS Newsstand 应用程序收到远程通知而导致 Web 服务器流量高峰?

Apache 无法在 Ubuntu 上的 AMPPS 中启动

.htaccess - 正确的userdir.conf为此.htaccess

php - 如何处理 .htaccess 规则中的 & 和/等特殊字符?

asp.net-mvc - 在 MVC 和 WCF 应用程序中共享 ASP.Net 应用程序缓存

ajax - Apache Tomcat 8.5.2 + Resteasy CORS 过滤器突然停止工作

python - 如何解决: Truncated or oversized response headers received from daemon process

php - 仅增加一个 PHP 页面的 Max_input_vars 限制

php - 由于缓存,CakePHP Flash 消息未显示

java - 我应该使用 HashTable 还是 HashMap 作为数据缓存?