These are my URIs



I need 2 separated location block for these URIs in Nginx because I want to cache first one and not cache the second one. How can I do that?

Additional: Also have question about "get_all_posts" request. Users are ganna fetch this URL. Each of them has unique "user_id" in their headers. Also each user should be able to get data based on his user_id (only get posts if this user_id is the owner of the post). Example:

User by user_id 10   should get posts A,B
User by user_id 11   should get posts C,D

If I pass them to upstream, they will get different data based on their user_id and is correct. I want to cache their response individually based on their headers['user_id'] field for request "/posts.php?action=get_all_posts". If I cache this request universally, every user will get same data and its not right on this case. How can I do that?

  • 1
    Or use the same location but set expires using a map. See this answer – Richard Smith Feb 14 at 10:11
  • @RichardSmith nice its cool solution. I also added Additional question could you please check that out? – Sami Al Morshedi Feb 14 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.