roadrunner-server / roadrunner-plugins

📦 Home for the roadrunner plugins
MIT License
25 stars 9 forks source link

[BUG] A http.headers.static.response in inserted into all responses instead of just static responses #115

Closed victor-sudakov closed 2 years ago

victor-sudakov commented 2 years ago

Roadrunner 2.5.3 is configured to insert the Cache-Control: "public, max-age=700" header into static responses. Instead, it inserts it into all responses.

HTTP session (the second Cache-Control header is generated by the PHP app):

GET /auth/testing/with_sleep/1001/ HTTP/1.0
Connection: Keep-Alive
X-VAS-BENCH: ApacheBench
Host: XXXXXXXXXXXX
User-Agent: ApacheBench/2.3
Accept: */*

HTTP/1.1 200 OK
Date: Fri, 12 Nov 2021 07:17:50 GMT
Content-Type: application/json
Connection: close
Cache-Control: public, max-age=700
Cache-Control: no-cache, private
Vary: Accept-Encoding
X-Powered-By: RoadRunner

rr config snippet:

http:
  address: 0.0.0.0:8060
  middleware: ["headers", "static", "gzip"]
  pool:
    num_workers: 30
    max_jobs: 700
    supervisor:
      exec_ttl: 60s
  headers:
    response:
      X-Powered-By: "RoadRunner"
  static:
    dir: "public"
    forbid: [".php"]
    calculate_etag: true
    response:
      Cache-Control: "public, max-age=700"
victor-sudakov commented 2 years ago

The documentation at https://roadrunner.dev/docs/http-static is ambiguous: what level should "static" be on, http.static or http.headers.static or http.address.static?

rustatian commented 2 years ago

@victor-sudakov I have updated the documentation. If it's not clear from the docs, please, feel free to inspect the full reference https://github.com/spiral/roadrunner-binary/blob/master/.rr.yaml

victor-sudakov commented 2 years ago

@victor-sudakov I have updated the documentation.

Looks clean now!