2016-07-07 114 views
2

我使用Zend框架的,我有很多CSS文件的這樣如何爲css.php設置過期標題?

http://www.example.com/css.php?request=application%2Fthemes%2Flove%2Ftheme.css&c=2146&pageStart=15376&pageEnd=256358

如何設置過期頭的css.php? 事實上,我的.htaccess不能使用它。

我.htacess:

<IfModule mod_expires.c> 
# Enable expirations 
ExpiresActive On 
# Default directive 
ExpiresDefault "access plus 1 month" 
# My favicon 
ExpiresByType image/x-icon "access plus 1 year」 
# Images 
ExpiresByType image/gif "access plus 1 month" 
ExpiresByType image/png "access plus 1 month" 
ExpiresByType image/jpg "access plus 1 month" 
ExpiresByType image/jpeg "access plus 1 month" 
# CSS 
ExpiresByType text/css "access 1 month」 
# Javascript 
ExpiresByType application/javascript "access plus 1 year" 
</IfModule> 

謝謝

回答

1

請嘗試在.htaccess以下

<IfModule mod_headers.c> 
    <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"> 
    Header set Cache-Control "max-age=2678400, public" 
    </filesmatch> 
    <filesmatch "\.(html|htm)$"> 
    Header set Cache-Control "max-age=7200, private, must-revalidate" 
    </filesmatch> 
    <filesmatch "\.(pdf)$"> 
    Header set Cache-Control "max-age=86400, public" 
    </filesmatch> 
    <filesmatch "\.(js)$"> 
    Header set Cache-Control "max-age=2678400, private" 
    </filesmatch> 
</IfModule> 
+0

我用你的.htaccess,但一切都沒有改變 – Rocstar

+0

如何要檢查的東西有緩存後更改? :) – Sree

+0

是的,我已經與谷歌的PageSpeed Insights進行了檢查:) – Rocstar