2014-05-18 97 views
0

海兰, 我有我的Drupal网站,我想缓存图像的家庭,但如果在htaccess的写:只缓存一个带有“.htaccess”而不是所有图像(.png)的图像(.png)?

## EXPIRES CACHING ## 
    <IfModule mod_expires.c> 
    ExpiresByType image/png "access 1 year" 
    </IfModule> 
    ## EXPIRES CACHING ## 

这将是缓存中的所有文件(巴纽)...

我想只缓存一个image.png;所以我问你是否有一种方法缓存只有一个规则在“.htaccess”中的一个元素? 是可能的?

谢谢:))

再见来自意大利)

编辑:

可以写入也:

## 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 ## 

???

,最后,如果我有两个图像(.PNG)(被sm.pngË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

我有写这样的:

<FilesMatch '(image|small)\.png$'> 
    ExpiresByType image/png "access 1 year" 
</FilesMatch> 

,但如果我使用“页面速度测试谷歌”或“Pingdom的工具”,而不是结果图像small.png缓存 哪里是电子恐怖?也许我需要插入图像的网址?

+0

没有任何关于该问:/ – Borja

回答

0

是的,你可以使用FilesMatch指令匹配和目标只有一个文件或设置匹配某些缓存行为的文件:

<FilesMatch 'image\.png$'> 
    ExpiresByType image/png "access 1 year" 
</FilesMatch> 

编辑:按照您编辑的问题,你可以使用:

<IfModule mod_expires.c> 
    <FilesMatch '(image|sm)\.png$'> 
    ExpiresByType image/png "access 1 year" 
    </FilesMatch> 
</IfModule> 
+0

所以,如果我的形象是 “sm.png” 我需要这样写: – Borja

+0

你离开你的评论不完整? – anubhava

+0

我需要写这个吗? : ## EXPIRES CACHING ## ExpiresByType图像/ PNG‘的访问权限1年’ ## EXPIRES CACHING ## – Borja

0

是的,但我想以这样的方式

1)

 <FilesMatch '(image|sm)\.png$'> 
     ExpiresByType image/png "access 1 year" 
    </FilesMatch> 

但非功能

 <FilesMatch "^(sm)\.png$"> 
     ExpiresByType image/png "access plus 1 year" 
     </FilesMatch> 

不funcion