M
M
Michael2018-04-30 17:45:35
Nginx
Michael, 2018-04-30 17:45:35

How to set up caching for development in nginx?

I would like everything to be cached when the console is closed, and when it is open, everything is loaded every time again. This applies to the file cache in nginx and the cache in the browser. Because without a cache there will be long downloads, and with a cache it is impossible to work normally with the same js.
1. How to tell nginx to update the file cache if the file has changed?
2. Is the Disable Cache checkbox in the developer console enough to ensure that a new version is always loaded on the browser side?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-05-01
@vaajnur

1. Using caching, the application will generate the page once and store the result in memory for some time (called TTL). Until the TTL expires, the client will receive the stored version of the page in memory.
If the user has any Cookies set, caching can be disabled:

location / {
        if ($http_cookie ~* ".+" ) {
            set $do_not_cache 1;
        } 
    }

2. Disable cache (while DevTools is open) should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question