Advanced-administration-handbook
Advanced-administration-handbook copied to clipboard
Do not cache all JSON requests (API-REST) in nginx
As per https://fosstodon.org/@webaware/110037286062251716
In nginx, we should not cache JSON requests in some cases.
if ($http_accept = "application/json") {
set $no_cache 1;
}
More information related:
- https://snippets.webaware.com.au/snippets/caching-oembed-with-nginx/
- https://aus.social/@rmccue/110020902246277742
Check publishing the REST API and also check caches from PUT, POST, DELETE at https://github.com/WordPress/Advanced-administration-handbook/blob/main/server/nginx.md#nginx-fastcgi_cache
Some information related with JSON and the Fediverse at https://github.com/pfefferle/wordpress-activitypub/blob/master/includes/class-activitypub.php#L78-L81
In nginx, we should not cache JSON requests in some cases.
if ($http_accept = "application/json") { set $no_cache 1; }
as activitypub supports 4 different json-ish mime-types, it might be better not to cache if mimetype is text/html
?
if ($http_accept != "text/html") {
set $no_cache 1;
}
@pfefferle any suggestions?