简体   繁体   English

mod_expires没有在JPEG图像上设置缓存控制头

[英]mod_expires not setting cache-control headers on JPEG images

I can't figure out why plain old JPEG images (about a dozen, < 10 KB each) in a website I'm working on won't take the cache-control headers they're being force feed. 我无法弄清楚为什么在我正在处理的网站中,普通的旧JPEG图像(大约十几个,每个< 10 KB )不会占用缓存控制头,因为它们是强制进给的。 The .htaccess rules I'm using are based off the most recent HTML5 Boilerplate .htaccess file (relevant section below). 我正在使用的.htaccess规则基于最新的HTML5 Boilerplate .htaccess文件 (下面的相关部分)。 What's weird is there's about the same amount of PNGs in the site and, except for two of them, the cache-control headers work perfectly. 有什么奇怪的是,网站中有大量相同数量的PNG,除了其中两个外,缓存控制标头工作正常。

<IfModule mod_expires.c>
  ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault                          "access plus 1 month"

...

# media: images, video, audio
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"

...

  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>

</IfModule>

(ellipsis indicate superfluous ExpiresByType rule sections removed) (省略号表示删除了多余的ExpiresByType规则部分)

I've gone right through from my /etc/apache2/apache2.conf file through to pretty much every conf file included from there and can find no reasonable explanation. 我已经从我的/etc/apache2/apache2.conf文件直接到了那里包含的几乎所有conf文件,并且找不到合理的解释。 I've also fiddled, Pagesped and Chrome audited it to death for hours, and I'm still clueless. 我已经摆弄,Pagesped和Chrome审核了几个小时的死亡,我仍然无能为力。

Edit: As mentioned below, there is only one .htaccess file in the web root for this website. 编辑:如下所述,此网站的Web根目录中只有一个.htaccess文件。 The JPEGs are coming through with the mime-type image/jpeg fine but the cache-control headers are missing and I can't figure out why. JPEG正在使用mime-type image/jpeg但缓存控制头文件丢失了,我无法弄清楚原因。

I added no-transform to the mod_headers section and sure enough, it all works as expected. 我在mod_headers部分添加了no-transform ,果然,它都按预期工作。 Now I can give the wall a break from my forehead. 现在我可以让我的额头从墙上休息一下。

  <IfModule mod_headers.c>
    Header append Cache-Control "public, no-transform"
  </IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM