简体   繁体   中英

Cache big PHP files in client browser - status '200 ok' instead of '304 not modified' - Apache

I modified the .htaccess at root like that:

ExpiresActive On
ExpiresDefault "access plus 300 seconds"

ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 day"
ExpiresByType text/php "access plus 1 day"
ExpiresByType text/html "access plus 1 day"

I also added those lines to the Apache file configuration ( httpd.conf ):

LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so

But browser doesn't seem to cache the katalog.php .

点击查看图片

I tried to change headers via the php but it just crashed the file, I couldn't access it.

I would like to cache it with "no-cache" (to check if it's still the same) because it takes time to download it every time (13.3MB ...), even when user press "backspace" button...

Finally managed to cache this big html content I used this : jonasjohn.de/snippets/php/caching.htm (without using e-tag) and apcu php extension to store an application scoped variable. ( to check if katalog has been updated : I compare the app scoped varaible to a $_session variable , if they're the same I dont load the content)

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