如何设置使用的.htaccess JPG文件的整个文​​件夹的缓存失效周期 [英] How to set the cache expiry period of a whole folder of jpgs using .htaccess

查看:136
本文介绍了如何设置使用的.htaccess JPG文件的整个文​​件夹的缓存失效周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何设置使用的.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.

这篇关于如何设置使用的.htaccess JPG文件的整个文​​件夹的缓存失效周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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