CSS Font gecached

felsi

Banned
Registriert
Mai 2007
Beiträge
556
Hallo,

ich habe die Google Fonts meiner Seite aktualisiert (Wechsel von Raleway zu Open sans). Nun stelle ich fest, dass bei Besuchern, die früher bereits auf meiner Seite waren, eine serif Schrift angezeigt wird. Im Inkognito-Modus passt alles, daher vermute ich, dass es am Cache liegt.

Nun gibt es ja Leute, die leeren niemals ihren Cache. Heißt dass, das bei diesen dann für immer die falsche Schriftart angezeigt wird? Oder verfällt der Cache eventuell irgendwann?

Oder kann ich da irgendetwas machen?

Danke
 
Der Webserver sagt dem Besucher, wie lange eine Datei gültig ist, hängt also von der Einstellung ab (Im Nginx heißt sie glaub ich expire). Du kannst an den Pfad der CSS Datei im HTML einen String/Timestamp anhängen, um den Browser zu zwingen, die Datei neu zu laden, zum Beispiel /style.css?v=12345.

Edit: Zu langsam :rolleyes:
 
Danke euch für die Erklärung. Das macht Sinn.

Gibt es eventuell auch die Möglichkeit, den Cache über die htaccess "zu leeren"? Problem ist nämlich, dass ich den Timestamp nicht direkt an die CSS hängen kann, da es sich um Magento handelt und das Template aus mehreren CSS zusammengesetzt wird.
 
Ja, bin mittlerweile drauf gekommen. Die Spur war richtig :)
Falls jemand mal das gleiche Problem hat:

There is a simple but cumbersome workaround that doesn't require any plugins and just uses built in Magento capabilities - useful if you just have to quickly do it on an existing site without wanting to risk installing any more code.

The idea is that you can use the merged CSS system to generate a cache busting file name.

As the merged CSS file name is a hash of all the files that are merged together you simply add an extra blank css file into the theme with a date stamp for a name.

So:

Turn on Merge CSS files in Configuration > Advanced > Developer
In your theme layouts find where you add CSS files to the head (typically page.xml) and add an extra stylesheet file, call it anything you want as long as the name is unique eg <action method="addCss"><stylesheet>css/cachebust_091014.css</stylesheet></action>
In your skin CSS folder create a new css file with that name, for the file contents I just put a comment saying what the file is for
Now push that live and flush the magento cache, the merged css file will now have a different name and your caches will be busted!

It's cumbersome as each time you want to bust the cache you need to change that file name, but it requires nothing other than built in Magento capabilities so it's handy if you find yourself stuck and need a quick fix!
 
Zurück
Oben