Welcome! Log In Create A New Profile

Advanced

NGINX Proxy Cache Cache-Control

June 22, 2018 03:42AM
Hello guys,

I'm having a hard time defining a proxy cache because my landing page doesn't generate any HTML which can be cached. Quit complicated to explain, let me show you some logs and curl requests:

curl:

curl -I https://....info/de
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 21 Jun 2018 11:56:15 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 135883
Connection: keep-alive
Keep-Alive: timeout=5
X-Magnolia-Registration: Registered
Access-Control-Allow-Origin: ...
Access-Control-Allow-Methods: GET, OPTIONS, HEAD
Access-Control-Allow-Headers: X-PINGOTHER, Origin, X-Requested-With, Content-Type, Accept
Cache-Control: max-age=60, public
Expires: Thu, 21 Jun 2018 11:57:15 GMT
Last-Modified: Thu, 21 Jun 2018 11:55:46 GMT
X-UPSTREAM: 10.6.198.11:8080
...

NGINX Access Logs:

[22/Jun/2018:09:35:24 +0200] Cache: - 10.6.198.12:8080 0.022 304 865 IP ...-com.stage.....info /de
[22/Jun/2018:09:35:26 +0200] Cache: HIT - - 200 1151 IP ...-com.stage.....info /.resources/img/favicon.ico

NGINX Locations:

location ~* \.(?:bmp|css|gif|ico|jng|jpe?g|js(on)?|png|svgz?|tiff?|wbmp|webp)$ {
# caching
expires max;
proxy_cache stage.....info_proxy-cache;
proxy_cache_lock on;

# custom lines
proxy_cache_use_stale error timeout updating invalid_header http_500 http_502 http_503 http_504;

# proxy pass
proxy_pass http://public.stage;

}


location ~* \.(?:html)$ {
# caching
expires 15s;
proxy_cache stage.....info_proxy-cache;
proxy_cache_lock on;

# custom lines
proxy_cache_use_stale error timeout updating invalid_header http_500 http_502 http_503 http_504;

# proxy pass
proxy_pass http://public.stage;

}

I'm able to cache all static assets with proper file extension like .png, .css, etc. pp. so this works like expected. My question is: is it possible to define the caching behaviour because of the Cache-Type? My idea is to take the result like "Content-Type: text/html;charset=UTF-8" and then to proxy cache it if it is text/html. Does it make sense?

Cheers,
Szop
Subject Author Posted

NGINX Proxy Cache Cache-Control

Szop June 22, 2018 03:42AM

Re: NGINX Proxy Cache Cache-Control

pbooth June 22, 2018 12:54PM

Re: NGINX Proxy Cache Cache-Control

Szop June 26, 2018 12:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 181
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready