| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| computer:web [2019-02-09 08:46] – skrupellos | computer:web [2019-02-09 08:58] (current) – removed skrupellos |
|---|
| ====== Modern Web ====== | |
| |
| ===== Cache ===== | |
| Hier werden nur Caching Headers im Response von GET Request behandelt. | |
| |
| ==== Einträge dem Cache hinzufügen (Cacheability) ==== | |
| |
| Algorithmus zur Bestimmung der Cachebarkeit [([[https://www.greenbytes.de/tech/webdav/rfc7234.html#response.cacheability]])] | |
| <code> | |
| if( | |
| Methode speicherbar && | |
| Statuscode unterstützt && | |
| !request.no-store && | |
| !response.no-store && | |
| (shared => !response.private) && | |
| ( (shared => !request.Authorization) || unless the response explicitly allows it (see Section 3.2) ) && | |
| ( | |
| response.Expires || | |
| response.max-age || | |
| (shared && response.s-maxage) || | |
| (response.Cache-Control Extension (see Section 5.2.3) that allows it to be cached) || | |
| (response.status.cacheable_by_default) || | |
| (response.public) | |
| ) | |
| ) { | |
| Vermutlich Speichern | |
| } | |
| else { | |
| Definitiv nicht speichern | |
| } | |
| </code> | |
| |
| Zu den Statuscodes die standardmäßig cachebar sind gehören unter anderem: 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, und 501 [([[https://www.greenbytes.de/tech/webdav/rfc7231.html#rfc.section.6.1.p.2]])] | |
| |
| /!\ Mit ''public'' können auch POST und Auth Resourcen gecached werden [(https://www.mnot.net/blog/2012/09/24/caching_POST)][([[https://www.greenbytes.de/tech/webdav/rfc7231.html#rfc.section.4.3.3.p.4]])]. Ohne genaue Erklärung äusert sich auch eBay wie es [[https://www.ebayinc.com/stories/blogs/tech/caching-http-post-requests-and-responses/|POST requests cached]]. | |
| |
| |
| ==== Einträge aus dem Cache löschen (Invalidation) ==== | |
| |
| ==== Einträge aus dem Cache holen ==== | |
| * Ein GET Eintrag kann eine GET oder eine HEAD Anfrage beantworten [([[https://www.greenbytes.de/tech/webdav/rfc7231.html#rfc.section.4.3.1.p.5]])]. | |
| * Ein HEAD Eintrag kann eine HEAD Anfrage beantworten [([[https://www.greenbytes.de/tech/webdav/rfc7231.html#rfc.section.4.3.2.p.3]])]. | |
| * Ein POST Eintrag kann | |
| * eine GET Anfrage beantworten, wenn der Eintrag ''Content-Location'' gleich der Anfrage URI und den Status-Code 200 hat [([[https://www.greenbytes.de/tech/webdav/rfc7231.html#rfc.section.4.3.3.p.4]])]. | |
| |
| ==== Weiteres ==== | |
| |
| <WRAP center round important 60%> | |
| Dieser Abschnitt ist noch hochgradig Falsch! | |
| </WRAP> | |
| |
| * public proxy (shared cache) vs private browser cache | |
| * Neu Laden vs validieren | |
| |
| ^ ''Cache-Control'' vom Server ^ Für ^ Funktion ^ Typ ^ | |
| | ''%%no-cache%%'' | | Immer -> validieren | Cachability | | |
| | ''%%public%%'' | | Private (V) / Shared (V) | Cachability | | |
| | ''%%private%%'' | Shared | Private (V) / Shared (X) | Cachability | | |
| | ''%%max-age=<seconds>%%'' | Private / Shared | Relative Cache Zeit | Expiration | | |
| | ''%%s-maxage=<seconds>%%'' | Shared | Relative Cache Zeit (vorrang vor ''Expires'' und ''s-maxage'') | Expiration | | |
| | ''%%must-revalidate%%'' | Private / Shared | Abgelaufen -> validieren | Re{validate,loading} | | |
| | ''%%proxy-revalidate%%'' | Shared | Abgelaufen -> validieren | Re{validate,loading} | | |
| | ''%%immutable%%'' | | Nicht abgelaufen -> verwenden (auch bei F5, aber nicht bei Shift+F5) / Abgelaufen ->Nicht verwenden [(http://bitsup.blogspot.com/2016/05/cache-control-immutable.html)] | Re{validate,loading} | | |
| | ''%%no-store%%'' | | Cachability: Private (X) / Shared (X) | Other | | |
| | ''%%no-transform%%'' | | Gecachten content nicht verändern (z.B. Optimieren) | Other | | |
| |
| |
| * https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching | |
| * [[https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching|Entscheidungsbaum, welche ''Cache-Control'' direktiven verwendet werden sollen]] | |
| * https://www.slideshare.net/martinmartin7777/http-caching-basics-66553113 | |
| * https://www.keycdn.com/blog/http-cache-headers | |
| * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | |
| * https://www.fastly.com/blog/understanding-vary-header-browser | |
| * https://www.digitalocean.com/community/tutorials/web-caching-basics-terminology-http-headers-and-caching-strategies | |
| * [[https://redbot.org/|REDbot]]: Caching Header online analyse tool | |
| * Preload ggf. auch bei Edge caches | |
| * POST, PUT und DELETE invalidieren private und shared cached. [([[https://www.mnot.net/blog/2006/02/18/invalidation]])] | |
| * [[https://www.greenbytes.de/tech/webdav/rfc7234.html|RFC 7234]]: Hypertext Transfer Protocol (HTTP/1.1): Caching | |
| * [[https://www.greenbytes.de/tech/webdav/rfc7231.html|RFC 7231]]: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content | |
| * [[https://greenbytes.de/tech/webdav/draft-ietf-httpbis-cache-03.html|draft-ietf-httpbis-cache-03]]: HTTP Caching (obsoletes RFC 7234) | |
| * [[https://github.com/mnot/redbot/blob/master/redbot/message/cache.py#L17|REDbot's Algorithmus zur Cache Header Auswertung]]. | |
| * [[http://www.iana.org/assignments/http-cache-directives/http-cache-directives.xhtml|Liste an ''Cache-Control'' direktiven]] bei der IANA. | |
| * [[https://www.mnot.net/blog/2017/03/16/browser-caching|Zusammenfassung wie Browser Caching umsetzen]] (Kompatibilitäts-Testergbnisse) | |
| * [[https://github.com/kornelski/http-cache-semantics/blob/master/index.js|JavaScript implementierung eines Caches]]. | |