简体   繁体   中英

Expires Header with a .php output javascript

I have creating a minify/obfusctor/gzip script in PHP of all my JS and CSS files but I can't expire but I have put this in my .htaccess:

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>

I want to expire all types text/javascript and text/css even if the extractor is a PHP file.

How can I do that?

Thx!


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

Here is the entire 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

Okay resolved, i used mod_expires and i removed the Header append for PHP files.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM