Problem/Motivation
We have a Drupal Commerce checkout using an off-site iframe for payment. It pings a callback controller and with some other logic we load a route using a ?refid=
query parameter. Despite this value changing, or being present and then not, the page is HIT after first view by dynamic page cache
Data from Chrome dev tools network tab:
First request:
Request URL:https://example.com/checkout/zuora/2804/payment?refid=
Request Method:GET
Status Code:302
cache-control:must-revalidate, no-cache, private
content-language:en
content-type:text/html; charset=UTF-8
date:Wed, 10 May 2017 21:32:35 GMT
expires:Sun, 19 Nov 1978 05:00:00 GMT
location:/checkout/2804/payment
server:nginx
status:302
x-drupal-dynamic-cache:MISS
Second request
Request URL:https://example.com/checkout/zuora/2804/payment?refid=REDACTED_VALUE
Request Method:GET
Status Code:302
cache-control:must-revalidate, no-cache, private
content-language:en
content-type:text/html; charset=UTF-8
date:Wed, 10 May 2017 21:32:35 GMT
expires:Sun, 19 Nov 1978 05:00:00 GMT
location:/checkout/2804/payment
server:nginx
status:302
x-drupal-dynamic-cache:HIT
Since the refid was present, it should have had a different location header.
For now, I have disabled cache on this route. But I had to move this callback out of our checkout plugin and into a custom route with caches disabled.
Proposed resolution
No idea. \Drupal\Core\Cache\Context\RouteCacheContext
checks the route parameters. Which is what the $dynamicPageCacheRedirectRenderArray
uses. It also checks request format.
Maybe also add url.query_args
as render context?
Remaining tasks
User interface changes
API changes
Data model changes