Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

apache - Create exception in mod_headers to avoid caching

Im running a PHP site, i have the following .htaccess:

The site works fine, but I have some URLs (html) that I wish not to be cached, for example:

How i can create a rule for out this URL?

Thank u :)

<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Cache-Control "max-age=604800, public "
</FilesMatch>

# BEGIN Expire headers
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 7200 seconds"
    ExpiresByType image/jpg "access plus 2592000 seconds"
    ExpiresByType image/jpeg "access plus 2592000 seconds"
    ExpiresByType image/png "access plus 2592000 seconds"
    ExpiresByType image/gif "access plus 2592000 seconds"
    AddType image/x-icon .ico
    ExpiresByType image/ico "access plus 2592000 seconds"
    ExpiresByType image/icon "access plus 2592000 seconds"
    ExpiresByType image/x-icon "access plus 2592000 seconds"
    ExpiresByType text/css "access plus 2592000 seconds"
    ExpiresByType text/javascript "access plus 2592000 seconds"
    ExpiresByType text/html "access plus 7200 seconds"
    ExpiresByType application/xhtml+xml "access plus 7200 seconds"
    ExpiresByType application/javascript A259200
    ExpiresByType application/x-javascript "access plus 2592000 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
</IfModule>
# END Expire headers

# BEGIN Cache-Control Headers
<IfModule mod_headers.c>
    <FilesMatch ".(ico|jpe?g|png|gif|swf|css|gz)$">
        Header set Cache-Control "max-age=2592000, public"
     </FilesMatch>
     <FilesMatch ".(js)$">
        Header set Cache-Control "max-age=2592000, private"
     </FilesMatch>
     <filesMatch ".(html|htm)$">
        Header set Cache-Control "max-age=7200, public"
     </filesMatch>
     # Disable caching for scripts and other dynamic files
     <FilesMatch ".(pl|php|cgi|spl|scgi|fcgi)$">
        Header unset Cache-Control
     </FilesMatch>
</IfModule>
# END Cache-Control Headers
question from:https://stackoverflow.com/questions/65878087/create-exception-in-mod-headers-to-avoid-caching

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...