开发者

Make all files in a folder (and subfolders) expire in a year using .htaccess

开发者 https://www.devze.com 2023-02-03 07:13 出处:网络
I want to set expiration headers for all the files in a \"media\" folder. A file looks like this: media/css/db38a57a8fa9de240b3ed5eb8be83691. I want it to be served with headers specifying it is to ex

I want to set expiration headers for all the files in a "media" folder. A file looks like this: media/css/db38a57a8fa9de240b3ed5eb8be83691. I want it to be served with headers specifying it is to expire i开发者_StackOverflow社区n a year or more.

How do I do that with .htaccess?


First , is mod_expire enabled in apache ? you can setup expiration like this if it's enabled

<ifmodule mod_expires.c>
    ExpiresDefault "modification plus 1 year"
</ifmodule>

Files will expire 1 year after they have been last modified , if you whant it based on access you can set it like so :

<ifmodule mod_expires.c>
    ExpiresDefault "access plus 1 year"
</ifmodule>

Have a look here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号