简体   繁体   中英

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. The .htaccess rules I'm using are based off the most recent HTML5 Boilerplate .htaccess file (relevant section below). 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.

<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)

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. I've also fiddled, Pagesped and Chrome audited it to death for hours, and I'm still clueless.

Edit: As mentioned below, there is only one .htaccess file in the web root for this website. 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.

I added no-transform to the mod_headers section and sure enough, it all works as expected. Now I can give the wall a break from my forehead.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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