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 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.