2010-11-20 91 views
0

我在PHP創建我所有的JS和CSS文件的縮小/ obfusctor/gzip的腳本以.php輸出,但我不能到期,但我已經把這個在我的.htaccess:Expires頭用JavaScript

ExpiresActive On 
ExpiresDefault A0 
ExpiresByType text/css "access plus 2 hours" 
ExpiresByType text/javascript "access plus 2 hours" 
ExpiresByType application/x-javascript "access plus 2 hours" 
Header append Cache-Control "proxy-revalidate" 

<FilesMatch "\.(xml|txt|html|js|css)$"> 
    ExpiresDefault A7200 
    Header append Cache-Control "proxy-revalidate" 
</FilesMatch> 

<FilesMatch "\.(php|cgi|pl|htm)$"> 
    ExpiresActive Off 
    Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform" 
    Header set Pragma "no-cache" 
</FilesMatch> 

我想過期所有類型文本/ javascript文本/ css即使提取器是PHP文件。

我該怎麼做?

Thx!


是的,我把header("Content-Type: text/javascript; charset=UTF-8");

下面是完整的HTTP標頭:

Date: Sat, 20 Nov 2010 19:02:05 GMT 
Server: Apache/2.2.11 (Win32) PHP/5.3.0 
X-Powered-By: PHP/5.3.0 
Content-Encoding: gzip 
Last-Modified: Sat, 20 Nov 2010 16:03:24 GMT 
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform 
Content-Length: 181781 
Pragma: no-cache 
Keep-Alive: timeout=5, max=99 
Connection: Keep-Alive 
Content-Type: text/javascript; charset=UTF-8 

200 OK 
+0

您是否正確指定了輸出的MIME媒體類型? – Gumbo 2010-11-20 16:39:45

回答

0

好解決,我用指定mod_expires和我刪除了標題附加的PHP文件。

ExpiresActive On 
ExpiresDefault A1 
ExpiresByType text/javascript A7200 
ExpiresByType application/x-javascript A7200 

<FilesMatch "\.(js)$"> 
Header append Cache-Control "max-age=7200, private" 
</FilesMatch> 
相關問題