2014-05-18 42 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