logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored by anyone.

Your donations will help to keep this site alive and well, and continuing the building of the binaries.



Nginx reverse proxy not caching all files.

 
Post new topic   Reply to topic    Apache Forum Index -> Other Software



View previous topic :: View next topic  
Author Message
gijs



Joined: 27 Apr 2012
Posts: 186
Location: The Netherlands

PostPosted: Sun 07 May '17 0:33    Post subject: Nginx reverse proxy not caching all files. Reply with quote

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: 240
Location: United Kingdom, London

PostPosted: Sat 13 May '17 10:26    Post subject: Reply with quote

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: 186
Location: The Netherlands

PostPosted: Sat 13 May '17 16:45    Post subject: Reply with quote

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


Post new topic   Reply to topic    Apache Forum Index -> Other Software
Page 1 of 1