luraproject / lura

Ultra performant API Gateway with middlewares. A project hosted at The Linux Foundation
https://luraproject.org
Other
6.35k stars 563 forks source link

Response caching not working #382

Closed nvlan closed 4 years ago

nvlan commented 4 years ago

Hello,

I have a microservice that for one specific endpoint (/ms/hello/) it replies with a JSON like {'Hello': name}. The microservice adds a Cache-Control header with public, max-age:10 values and the backend in kraken has the "github.com/devopsfaith/krakend-httpcache": {} configuration as extra_config. However, when I call the kraken endpoint I see that the reply arrives with a Cache-Control header that says public, max-age: 3600 and each time it calls the microservice instead of caching the response JSON.

The endpoint config is as follows:

  {
    "endpoint": "/krakend/saludo/{nombre}",
    "method": "GET",
    "output_encoding": "json",
    "concurrent_calls": 1,
    "backend": [
      {
        "url_pattern": "/devops-test-api-python/hello/{nombre}",
        "encoding": "json",
        "sd": "static",
        "extra_config": {
          "github.com/devopsfaith/krakend-httpcache": {}
        },
        "method": "GET",
        "host": [
          "http://localhost:8081"
        ],
        "disable_host_sanitize": false
      }
    ]
  }

Is this an expected behaviour? How could I properly test/validate if kraken is in fact caching the response?

Thanks a lot, kind regards!

kpacha commented 4 years ago

Your issue is related with the backend header not following the RFC. Try again with Cache-Control: public, max-age=10 (notice the = replacing the :)

github-actions[bot] commented 2 years ago

This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.