Nginx ajax caching

I use nginx for the proxy cache, and I had problems caching some ajax requests. Nginx does cache correctly for all pages, but not for ajax requests.

Uri for ajax requests: / process / leaveyourmessage / getMessages? id = XX

My location:

location / {
    proxy_pass http://mydomain.com:8080;
    proxy_cache microcache;
    proxy_cache_valid 200 5s;
    proxy_cache_use_stale updating;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

In the http block, I added:

proxy_cache_path /var/cache/nginx levels=1:2
                 keys_zone=microcache:5m max_size=1000m;

Does anyone know what the problem is? My back end is apache + php


I found a problem. Nginx respects cache control and finishes the header, and those ajax send it.

Writing "proxy_ignore_headers Management caching expires;" made him work.

+5
source share

All Articles