2010-11-20 9 views
0

Ich habe einen minify/obfusctor/gzip-Skript in PHP alle meiner JS und CSS Dateien zu erstellen, aber ich kann nicht verfallen, aber ich habe dies in meinem .htaccess setzen:Expires-Header mit einer .php Ausgabe 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> 

Ich möchte alle Typen Text/Javascript und Text/CSS ablaufen, auch wenn der Extractor eine PHP-Datei ist.

Wie kann ich das tun?

Thx!


ja i header("Content-Type: text/javascript; charset=UTF-8"); setzen

Hier ist die gesamte HTTP-Header:

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

Geben Sie den MIME-Medientyp Ihrer Ausgabe richtig an? – Gumbo

Antwort

0

Gut gelöst, verwendet i mod_expires und i entfernt die Kopfzeile für PHP-Dateien anhängen.

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

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