I’m trying to cache some static content in HAProxy. I did check all the limitations described in the configuration manual, and it seems to me I’m not falling into these cases, yet the proxy is always serving a static JS file from backend, instead of providing it from RAM.
I cannot figure out what’s wrong in my configuration.
thanks
[...]
backend app_italy_http_cluster
http-request cache-use app-memory-cache
http-response cache-store app-memory-cache
server italy22-01 italy22:80 check weight 100 inter 2s rise 2 fall 3 agent-check agent-port 5656 agent-inter 5s
server italy22-02 italy22-02:80 check weight 100 inter 2s rise 2 fall 3 agent-check agent-port 5656 agent-inter 5s
cache app-memory-cache
total-max-size 50
max-object-size 6291456
max-age 36000
process-vary on
This is the log of the request:
Nov 2 14:43:44 localhost haproxy[33616]: client:62777 [02/Nov/2023:14:43:44.332] app_frontend_web~ app_italy_http_cluster/italy22-02 0/0/1/1/154 200 2780129 - - --NI 1/1/0/0/0 0/0 "GET https://app.domain.it/dist/js/app.common.min.js?1234 HTTP/2.0"
This is the curl request:
curl -v "https://app.domain.it/dist/js/app.common.min.js?1234" -o app-common.js
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 1.2.3.4:443...
* Connected to app.domain.it (1.2.3.4) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
} [328 bytes data]
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* (304) (IN), TLS handshake, Unknown (8):
{ [19 bytes data]
* (304) (IN), TLS handshake, Certificate (11):
{ [3987 bytes data]
* (304) (IN), TLS handshake, CERT verify (15):
{ [264 bytes data]
* (304) (IN), TLS handshake, Finished (20):
{ [36 bytes data]
* (304) (OUT), TLS handshake, Finished (20):
} [36 bytes data]
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN: server accepted h2
* Server certificate:
* subject: CN=app.domain.it
* start date: Sep 22 16:53:08 2023 GMT
* expire date: Dec 21 16:53:07 2023 GMT
* subjectAltName: host "app.domain.it" matched cert's "app.domain.it"
* issuer: C=US; O=Let's Encrypt; CN=R3
* SSL certificate verify ok.
* using HTTP/2
* h2 [:method: GET]
* h2 [:scheme: https]
* h2 [:authority: app.domain.it]
* h2 [:path: /dist/js/app.common.min.js?1234]
* h2 [user-agent: curl/8.1.2]
* h2 [accept: */*]
* Using Stream ID: 1 (easy handle 0x129812400)
> GET /dist/js/app.common.min.js?1234 HTTP/2
> Host: app.domain.it
> User-Agent: curl/8.1.2
> Accept: */*
>
< HTTP/2 200
< date: Thu, 02 Nov 2023 14:43:44 GMT
< server: Apache
< x-frame-options: SAMEORIGIN
< last-modified: Thu, 02 Nov 2023 08:56:15 GMT
< etag: "2a691a-609278f74c4dc"
< accept-ranges: bytes
< content-length: 2779418
< cache-control: max-age=2592000, public
< expires: Sat, 02 Dec 2023 14:43:44 GMT
< report-to: {"group":"default","max_age":1800,"endpoints":[{"url":"/cspreport"}]}
< x-xss-protection: 1; mode=block
< x-content-type-options: nosniff
< content-security-policy: frame-ancestors 'self'; style-src 'self'; script-src 'self' 'unsafe-inline' ; img-src 'self'; connect-src 'self'; frame-src 'self'; font-src 'self'; media-src 'self'; object-src 'self'; manifest-src 'self'; form-action 'self';
< content-type: text/javascript; charset=utf-8
< x-frame-options: DENY
< strict-transport-security: max-age=16000000; includeSubDomains; preload;
< set-cookie: SRVNAME=; Expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; HttpOnly; Secure
<
{ [13309 bytes data]
100 2714k 100 2714k 0 0 8489k 0 --:--:-- --:--:-- --:--:-- 8535k
* Connection #0 to host app.domain.it left intact