MediaWiki HTTP cache headers
Jump to navigation Jump to search
(Redirected from MediaWiki caching)
This page may be outdated or contain incorrect details. Please update it if you can.
MediaWiki caching headers are sent mainly in OutputPage.php, function
sendCacheControl(). The headers sent depend mainly on the action and if a cookie is sent by the browser.
- s-maxage: Tells intermediate caches how long they should consider the content to be valid without ever checking back. This needs to be hidden from caches we can't purge, otherwise users won't see changes.
- max-age: For how long browsers should deem the content as up-to-date. We allow clients to keep the page (the "private" header allows this) but tell them to send a conditional
if-modified-sincerequest. For this the
Last-modifiedheader is needed; We set the header value to the last modification time or - if we don't have it - to the current time minus one hour. Images and stylesheets (including the generated ones that represent the user's preference selections) have
max-age > 0to avoid reloading those on each request. This is the reason why users have to refresh their cache after changing their preferences.
- private: Allows browsers to cache content.
Cache-Control: private, s-maxage=0, max-age=0, must-revalidate
- This is required for client-side caching, as without it browsers don't know what to base their
if-modified-sincerequests on. If the page hasn't changed the cache will only respond with a 304 (unchanged) status code, and only the response code and headers are transferred.
- Tells downstream proxy caches to cache the content depending on some values — if those values are different, serve another page for the same url.
- Accept-Encoding Clients that don't support gzip transfer-encoding don't get compressed pages.
- Cookie Make sure logged-in users (which send a cookie) get pages with their user name and preferences.
vary: Accept-Encoding, Cookie