简体   繁体   中英

Add expires header for specific files

I am attempting to add an expires header for a specific file. It doesn't seem to be working and keeps setting it to one week. I'm not sure if it's a syntax error or the way I am trying to target the file.

Here is the code I am using in my HT Access.

  <FilesMatch "^(vendor.min.js)$">

    ExpiresByType text/javascript "access plus 4 weeks"

  </FilesMatch>

In what context are your other Expires directives set? There are some counter-intuitive rules of how sections are merged, for example Location has higher precedence (evaluated later) than Directory/Files/FilesMatch.

I'd suggest changing the context of wherever your "1 week" rules are today.

https://httpd.apache.org/docs/2.2/sections.html

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