question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi,

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:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Atinuxcommented, Jan 7, 2021

I would still like to implement it using a slug /_content/:query as GET request, for permanent caching

0reactions
farnabazcommented, Dec 14, 2022

This enhancement already done in the nuxt/content@v2 and all the requests are GET and cacheable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content Caching Definition - Avi Networks
Content caching is a performance optimization mechanism in which data is delivered from the closest servers for optimal application performance.
Read more >
What is content caching on Mac? - Apple Support
Content caching is a macOS service that helps reduce internet data usage and speed up software installation on Mac computers, iOS and iPadOS...
Read more >
What is Content Caching? - StackPath
Content caching is a performance optimization mechanism in which data is delivered from the closest servers for optimal application performance.
Read more >
What is Caching and How it Works - AWS
A cache is a high-speed data storage layer which stores a subset of data, ... Networking layers including Content Delivery Networks (CDN) and...
Read more >
HTTP caching - MDN Web Docs
The HTTP cache stores a response associated with a request and reuses the stored ... If a response contains personalized content and you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found