Caching content
See original GitHub issueHi,
I am running my Nuxt website behind a CDN which reduces page load time by caching responses. Static content as served by this API is a good candidate for that.
Unfortunately, responses from the content API are not cacheable because the query builder always sends a HTTP POST request:
https://github.com/nuxt/content/blob/f5b3cf7dc73db3d6de9827c58e713501f68f6f84/packages/content/templates/query-builder.js#L100
POST cannot (should not) be cached. GET should be used for read access to data.
I’ve seen that the backend middleware already has an implementation to read query parameters from GET requests:
https://github.com/nuxt/content/blob/f5b3cf7dc73db3d6de9827c58e713501f68f6f84/packages/content/lib/middleware.js#L34
Is it possible to switch the request method to GET by default?
In addition to that, I’d like to set Cache-Control: public, max-age=1234
so that the CDN and the browser can keep the response in cache for a while.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
I would still like to implement it using a slug /_content/:query as GET request, for permanent caching
This enhancement already done in the nuxt/content@v2 and all the requests are GET and cacheable.