为特定图像添加过期标题 [英] Add Expires Headers for Specific Images

查看:82
本文介绍了为特定图像添加过期标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过的所有过期标题文章都或多或少地提供了以下解决方案:

All of the expires headers articles I've looked at give more or less the following solution:

ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000

但是对我来说这没有意义,因为我知道我的哪些图像会更改,哪些不会更改,所以我希望能够将特定的到期日期添加到特定的图像文件。我该怎么办?

But it doesn't make sense to me because I know which of my images are going to change and which aren't, so I want to be able to add specific expiration dates to specific image files. How would I go about this?

推荐答案

您可以使用 FilesMatch ,例如。

<FilesMatch "\.(js|css)$">
  ExpiresActive on 
  ExpiresDefault "access plus 1 month"
</FilesMatch>

或者对于某些特定文件:

Or for some specific files:

<FilesMatch "^(example.js|sample.css)$">
  ExpiresActive on 
  ExpiresDefault "access plus 1 month"
</FilesMatch>

这篇关于为特定图像添加过期标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆