[英]cache only one image (.png) with “.htaccess” and not all images(.png)?
Hy, I have in the home of my drupal site an image that i want cache, but if write this in the htaccess: 嗨,我在drupal网站的首页中有一个要缓存的图像,但是如果将其写在htaccess中:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresByType image/png "access 1 year"
</IfModule>
## EXPIRES CACHING ##
it will be cache all files (.png)... 它将缓存所有文件(.png)...
I want cache only one image.png; 我只想缓存一个image.png; so i ask you if there is a way cache only one element with a rule in the ".htaccess" ????
所以我问你有没有办法在“ .htaccess”中只缓存一个带有规则的元素? Is possible??
有可能吗?
Thank you :)) 谢谢 :))
Bye from italy ;) 来自意大利的再见;)
EDIT : 编辑:
is possible write also: 也可以写:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
<FilesMatch 'image\.png$ sites/all/themess/mysubtheme/images/sm.png'>
ExpiresByType image/png "access 1 year"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##
??? ???
and finally, if i have two images (.png) (are sm.png e small.png) i write this: 最后,如果我有两张图片(.png)(是sm.png e small.png),我会这样写:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
<FilesMatch 'image\.png$ sites/all/themess/mysubtheme/images/sm.png'>
ExpiresByType image/png "access 1 year"
</FilesMatch>
<FilesMatch 'image\.png$ sites/all/themess/mysubtheme/images/small.png'>
ExpiresByType image/png "access 1 year"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##
2° EDIT : 2°编辑 :
i have write this: 我写这个:
<FilesMatch '(image|small)\.png$'>
ExpiresByType image/png "access 1 year"
</FilesMatch>
but if i use "page speed test Google" or "pingdom tool", not result that the image small.png is cached Where is the error ? 但是,如果我使用“页面速度测试Google”或“ pingdom工具”,则不会导致图像small.png被缓存了错误在哪里? Maybe i need insert the image's url ???
也许我需要插入图片的网址???
Yes you can use FilesMatch
directive to match and target only one file or set of matching files for certain caching behavior: 是的,对于某些高速缓存行为,您可以使用
FilesMatch
指令来匹配和定位一个文件或一组匹配文件:
<FilesMatch 'image\.png$'>
ExpiresByType image/png "access 1 year"
</FilesMatch>
EDIT: As per your edited question you can use: 编辑:根据您编辑的问题,您可以使用:
<IfModule mod_expires.c>
<FilesMatch '(image|sm)\.png$'>
ExpiresByType image/png "access 1 year"
</FilesMatch>
</IfModule>
yes but i tried in this way : 是的,但是我尝试过这种方式:
1) 1)
<FilesMatch '(image|sm)\.png$'>
ExpiresByType image/png "access 1 year"
</FilesMatch>
but non function 但不起作用
<FilesMatch "^(sm)\.png$">
ExpiresByType image/png "access plus 1 year"
</FilesMatch>
not funcion 不起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.