- πΈπͺSweden kevineinarsson
Attached a test + patch (not a clean patch but it... works(?)) Maybe need to check if these values are null too.
- Status changed to Needs work
almost 2 years ago 12:47pm 10 March 2023 - πΈπͺSweden kevineinarsson
The patch doesn't work, s-maxage and max-age are always set to the same value.
The configuration form says that the 3xx/404/5xx max-age value should be the same as 200 responses. If that's the case, why is setClientTtl called? - First commit to issue fork.
- Merge request !16Add test from http_cache_control-3276742-test-only.patch β (Open) created by dieterholvoet
- π§πͺBelgium dieterholvoet Brussels
I don't understand how the code even gets past
$response->isCacheable()
. That method contains the following logic:public function isCacheable(): bool { if (!\in_array($this->statusCode, [200, 203, 300, 301, 302, 404, 410])) { return false; } if ($this->headers->hasCacheControlDirective('no-store') || $this->headers->getCacheControlDirective('private')) { return false; } return $this->isValidateable() || $this->isFresh(); }
It explicitly disables caching for 404/302/301 responses, so if I'm understanding correctly the max-ages provided by this module for those status codes are never used, right?
- π§πͺBelgium dieterholvoet Brussels
A couple things I don't understand either about the current code:
- Why are the 404/302/301 TTL's being assigned to the maxage, even though their setting descriptions state they are only being used for s-maxages?
- Why is
setClientTtl()
used for max-ages andsetSharedMaxAge()
for s-maxages? The former considers theAge
header, the latter doesn't. - Why is the s-maxage set when it's the same as the max-age?
- Why is the configured s-maxage only used when it's > 0?
I'm afraid that fixing the first one would require a new major release. It's undocumented behaviour, but still behavior that people might depend on. I started a MR fixing 1, 2 and 3, which in turn also fixes this issue. I did keep the last one for now, but I decided to document it in the form.
Existing and new tests are passing, but it would be great if @josh waihi could review, just to make sure we're not missing anything here.