Answer the question
In order to leave comments, you need to log in
Help with setup
I want to implement the following scheme on nginx:
1. the client visits the site page
2. nginx checks if this page is in its cache:
2.1 if not, it accesses the application, gets the page and etag, gives it to the client
2.2 if the page exists, sends the header to the application If- None-Match to check the etag, which he remembered at step 2.1
2.2.1 if the application responded with 304 Not Modified, gives the client a page from its cache
2.2.2 if the application responded with 200 OK (the page has changed), then it works according to the scheme of clause 2.1
3. one and the same url can contain different content for authorized and unauthorized users.
to distinguish between them, a variable in the "csplthash" cookie is used. it just needs to be added to the nginx cache key (as I understand it, this is not difficult).
4. When accessing the url, nginx must pass all headers and cookies to the application, and give html from its cache by first validating it through etag.
Can someone tell me how to do it right?
Answer the question
In order to leave comments, you need to log in
proxy_cache_key with $cookie_csplthash for authorization-based caching.
I won't say anything about Etag. The nginx itself supports etag, and stores the headers given by the backend in the cache.
In general, nginx has $sent_http_HEADER parameters. Maybe add them to the cache key ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question