Review main Abandoned

58562[BUGFIX] Fix HTTP response headers when tempContent is sent

Benni Mack CR 0 V 0 Easy +14 −4 updated 10/28/18, 11:56

Commit message

When the infamous "Page is being generated" message pops up,
there are HTTP headers sent which are wrong.

a) "Expire" includes a typo and should be called "Expires"
b) "Retry-after" => the client should re-check in 30 seconds not 3600sec
c) Since "Cache-control" only contains "no-cache" but not "private"
this means that any proxy is allowed to keep this information as well,
as they may obey the no-cache directive. (quote from rfc7234:
"Note: Although it has been back-ported to many implementations, some
HTTP/1.0 caches will not recognize or obey this [no-cache] directive.")
That would prevent the possibility for clients to manually refresh, forcing
them to wait for the proxy-to re-ask again. We use a similar construct
("private, no-strict") in another scenario, so this is a "nice-to-have"
fix, since "Expires: 0" should do the job already.

Some additional notes are also added in the comments.

The main fix is to not cache these 503 requests anymore.

Some references:

Header "Expires" not "Expire" - http://httpd.apache.org/docs/current/mod/mod_expires.html

Cache-Control:

https://docs.fastly.com/guides/tutorials/cache-control-tutorial#do-not-cache
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
https://sookocheff.com/post/api/effective-caching/

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 1

Review log 1215

  1. Benni Mack uploaded patch set 1 10/03/18, 09:51

  2. TYPO3com voted on patch set 1 V +1 10/03/18, 10:02 Completed build in 10m 48s on Wed, 3 Oct, 12:02 PM Test Summary: 37792 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-29293

  3. Andreas Wolf commented on patch set 2 10/03/18, 10:42

    Published edit on patch set 1.
  4. TYPO3com voted on patch set 2 V +1 10/03/18, 10:54 Completed build in 12m 02s on Wed, 3 Oct, 12:54 PM Test Summary: 37792 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-29295

  5. Georg Ringer voted on patch set 2 CR +1 10/03/18, 11:08

  6. Benjamin Franzke commented on patch set 2 CR -1 10/03/18, 11:14

    on it
  7. Benjamin Franzke uploaded patch set 3 10/03/18, 12:40

  8. TYPO3com voted on patch set 3 V +1 10/03/18, 12:51 Completed build in 11m 02s on Wed, 3 Oct, 02:51 PM Test Summary: 37792 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-29301

  9. Benjamin Franzke commented on patch set 3 CR -1 10/03/18, 12:53

    I've rephrased the wording a bit to make clear why private may be ignored by proxies. Despite that, I do think "private" is wrong in this case, as the statuscode 503 is specified to be not cachable by default and therefore needs to be marked as cachable explicitly using "Cache-Control: public", see following quotes from rfc7231 and rfc7234: https://tools.ietf.org/html/rfc7231#section-6.1 Responses with status codes that are defined as cacheable by default (e.g., 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, and 501 in this specification) can be reused by a cache with heuristic expiration unless otherwise indicated by the method definition or explicit cache controls [RFC7234]; all other status codes are not cacheable by default. https://tools.ietf.org/html/rfc7234#section-4.2.2 heuristics can only be used on responses without explicit freshness whose status codes are defined as cacheable by default (see Section 6.1 of [RFC7231]), and those responses without explicit freshness that have been marked as explicitly cacheable (e.g., with a "public" response directive). Is there any realworld proxy that violates the specification in this regard so that "private" actually fixes that? If not I'd vote for leaving that out. Including it "just to be sure" becomes annoying when refactoring and cleaning up code, because it'll be hard to understand what that might have fixed ("back at that former time").
  10. Benjamin Franzke commented on patch set 3 10/03/18, 13:16

    When quoting those RFCs it also becomes clear that the caching instructions (Cache-Control, Pragma and Expires) are all unnecessary in this case. The real fix would be to send only the 503 status code and the "Retry-After" header. (yea, I know, we probably wouldn't want to take the risk to backport that change)
  11. Susi Moog commented on patch set 3 V -1 10/13/18, 12:06

    TypoScriptFrontendController.php:4254

    I get errors for non-string headers "Invalid header value for header "Expire"". The value must be a string or an array of strings."
  12. Susi Moog commented on patch set 3 10/13/18, 12:07

    see \TYPO3\CMS\Core\Http\Message::withHeader ll 208
  13. Stefan Neufeind commented on patch set 3 10/15/18, 15:22

    TypoScriptFrontendController.php:4254 Reply

    By reading I agree that triggering this error should be expected. Why was it no problem with the Expire-header, and not caught by tests? Should we do a separate change (task) to allow adding non-string-values (at least integer) in Http\Message and maybe simply cast that to string?
  14. Stefan Neufeind commented on patch set 3 10/15/18, 16:01

    Please find a proposed patch at https://review.typo3.org/58637 to also support adding integers as header-values.
  15. Benni Mack abandoned the change 10/28/18, 11:56