1

I built an api with next.js. I use a JSON file as a data source. I import it as a module. But if the content of the JSON changes, it still shows the first content, the same, when i started the server.

Is there a way to avoid caching JSON with import?

I need to get the JSON content, but also the updates in the JSON file, without restarting my api.

1 Answers1

1

If your Server returns the JSON files with a specific File-Extension like .json you could try to turn off the caching for those file-types:

Here is an example for ngnix-servers

Here is an example for apache-servers

Another possibility is to load the JSON via Javascript where you add some random parameter to the Query-Params of the URL Here is the Example

Marko Jozic
  • 146
  • 4