Ich habe alle JS auf meiner Website für eine Woche zwischenzuspeichern. Es gibt jedoch bestimmte Dateien, die ich mit einer höheren Häufigkeit aktualisieren muss. Daher habe ich Filesmatch zu bewirken, um die Ausnahme in meiner .htaccess-Datei verwendet:Änderungen in htaccess Expires Kopfzeile spiegelt sich nicht in Browser
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
# Favicon (cannot be renamed!)
ExpiresByType image/x-icon "access plus 1 week"
# HTML components (HTCs)
ExpiresByType text/x-component "access plus 1 month"
# HTML
ExpiresByType text/html "access plus 0 seconds"
# JavaScript
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
# Manifest files
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Media
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# Web feeds
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
# Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
<FilesMatch "^(ga\.js)$">
ExpiresActive on
ExpiresDefault "access plus 2 days"
</FilesMatch>
Die Ausnahmedatei an /sandboxassets/js/ga.js
ist und die .htaccess ich mit ist im Dokument root arbeite (/
). Jedoch scheinen der Browser diese Ausnahme nicht zu ehren und gibt die folgende Header für die Datei in Frage:
Accept-Ranges:bytes
Access-Control-Allow-Origin:*
Age:0
Cache-Control:max-age=604800
Content-Encoding:gzip
Content-Length:11967
Content-Type:application/javascript
Date:Thu, 02 Mar 2017 15:03:55 GMT
Expires:Thu, 09 Mar 2017 15:03:55 GMT
Last-Modified:Thu, 02 Mar 2017 15:00:01 GMT
Server:Apache Phusion_Passenger/4.0.10 mod_bwlimited/1.4 mod_fcgid/2.3.9
Vary:Accept-Encoding,User-Agent
Via:1.1 varnish-v4
X-Varnish:18808880
604800 Sekunden 1 Woche, die den Standard für alle JS Vermögen ist wie in meinem .htaccess definiert aber ich brauche es 172800 Sekunden (2 Tage). Was mache ich falsch? Gibt es auch eine Möglichkeit, dem Browser mitzuteilen, dass er auf die neueste Kopfzeile aktualisiert werden soll? Opera gibt eine 31536000 Sekunden (1 Jahr) zurück, was ich vor kurzem auf 1 Woche für alle JS geändert habe!
aktualisieren: Verwendung des folgenden Codes verursacht meine Seite komplett 500 mit einem Fehler zu brechen:
<Directory "/sandboxassets/js/">
AllowOverride All
<FilesMatch "ga\.js$">
Expires A172800
</FilesMatch>
<FilesMatch "tww\.js$">
Expires A172800
</FilesMatch>
</Directory>
ich es zuerst innen <IfModule mod_expires.c>
hinzugefügt und dann, nachdem sie unmittelbar und erleben die gleichen Fehler jedes Mal .
Dieser Code ist vollständig auf meiner Website. Ich habe die Frage mit dem genauen Code aktualisiert, den ich verwendet habe. – TheLearner
Ugh. Das tut mir leid. Ich werde herumstochern und sehen, was ich sonst noch finden kann. – malodie