Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Nginx reverse proxy not caching all files. |
|
Author |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Sun 07 May '17 0:33 Post subject: Nginx reverse proxy not caching all files. |
|
|
I'm setting up NGINX as reverse caching proxy for my IIS website.
I'm experiencing an issue with the caching of .png and.ashx files. Every time I check the response headers I see: x-cache-status: MISS
The other files are cached as expected.
NGINX is configured as caching reverse proxy with the following arguments:
Code: | location / {
proxy_pass https://IIS:443;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location ~* \.(html|css|jpg|png|gif|ico|js|axd|ashx)$ {
proxy_cache cache;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 301 302 3h;
expires 3h;
proxy_pass https://IIS:443;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache_revalidate on;
proxy_cache_min_uses 1;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_lock on;
}
}
}
|
I have no idea why the .png and .ashx files are not being cached. Any help is appreciated. |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Sat 13 May '17 10:26 Post subject: |
|
|
You should post @ https://forum.nginx.org/ the windows mailing list.
But from what i see this should fix your issue.
Code: |
location ~* \.(html|css|jpg|png|gif|ico|js|axd|ashx)$ {
proxy_cache cache;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 301 302 3h;
expires 3h;
proxy_pass https://IIS:443;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache_revalidate on;
proxy_cache_min_uses 1;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_lock on;
}
location / {
proxy_pass https://IIS:443;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
|
Make that your location setup and ordering.
If that does not work just post here one of the dev's or regular nginx guru's will help. https://forum.nginx.org/list.php?2 |
|
Back to top |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Sat 13 May '17 16:45 Post subject: |
|
|
Actually I set this up with Apache and found that the Cache-Control header was the issue.
I'm not planning on using Nginx because I have to recompile it to enable mod_pagespeed.
Instead I've opted for Apache, since I'm already familiar with it and can easily install the mod_pagespeed plugin. |
|
Back to top |
|
|
|
|
|
|