如何设置使用的.htaccess JPG文件的整个文​​件夹的缓存失效周期缓存、周期、如何设置、文件

2023-09-02 00:51:51 作者:独照.

我如何设置使用的.htaccess图像的整个文件夹?

缓存到期日

现在,我只想要一个特定的文件夹中的内容给予一个长期的高速缓存到期日。我目前使用下面的code(粘贴下面),但我觉得这是一个痛苦,因为我每次添加一个新的艺术片,我必须将它添加到这个列表。有没有我可以指定整个文件夹的方式?

 < FilesMatch(的CSS | main_banner.jpg | cart.png | main_logo.jpg |的favicon.ico | search_button.jpg | fp_banner.jpg)$>
   页眉设置缓存控制最大年龄= 2592000
< / FilesMatch>
 

解决方案

只要把该文件夹中的.htaccess文件。然后,所有你需要的是头设置缓存控制最大年龄= 2592000指令,无需担心 FilesMatch 状态。

How can I set the cache expiry date of a whole folder of images using .htaccess?

Right now, I only want the contents of one specific folder to be given a long cache expiry date. I'm currently using the following code (pasted below), but I find it a pain because every time I add a new piece of art, I have to add it to this list. Is there a way I can just specify the entire folder?

<FilesMatch" (.css|main_banner.jpg|cart.png|main_logo.jpg|favicon.ico|search_button.jpg|fp_banner.jpg)$">
   Header set Cache-Control "max-age=2592000"
</FilesMatch>

解决方案

Just put the .htaccess file in that folder. Then all you need is the Header set Cache-Control "max-age=2592000" directive, without worrying about the FilesMatch condition.