[tests] Add Vary: User-Agent to responses transformed by the test compilation plugin.
#522
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There seems to be a cache somewhere between the server hosting the tests (which runs this plugin) and the browsers we're testing on Sauce Labs. Without this header, this cache serves responses generated for one browser's requests to those of another browser, which may have different compliation settings.
These different browsers which seem to be having their responses mixed up are running in different OSs on different VM instances, so I don't think this cache could possibly be running anywhere on the client VM. Also, I've checked that the requests are in fact reaching the server and responses are being compiled - the response is just different by the time the browser receives it. This makes me think that the culprit is Sauce Labs Proxy, but the docs for Sauce Labs Proxy claim that it no longer caches.1 They also recently deprecated a
--no-proxy-cachingflag2, so I'm skeptical.Setting
Cache-Control: no-cachecan't be used to work around this because@web/test-runnerunconditionally installs server middleware3 that almost always setsCache-Control: public, max-age=31536000in non-interactive scenarios.4Fortunately, this unknown cache seems to be responsive to the
Varyrequest header. The plugin specifically uses theUser-Agentrequest header to determine compilation settings, so addingVary: User-Agentwill cause the cache to use fresh responses for any change in the UA.Footnotes
https://docs.saucelabs.com/secure-connections/sauce-connect/advanced/architecture/#sauce-connect-proxy-client ↩
https://wiki.saucelabs.com/pages/viewpage.action?pageId=48365781 ↩
cacheMiddlewareis added before...config.middleware, giving it higher precedence. It also callsawait ctx.next()before doing any work, so it always runs last and overwrites anyCache-Controlheader added by any usermiddleware: https://github.com/modernweb-dev/web/blob/da7901116322fc112ea45413e6be87f3f770f15e/packages/test-runner-core/src/server/TestRunnerServer.ts#L50 ↩
https://github.com/modernweb-dev/web/blob/fdcf2e59253c619aaa07938e5710f9db24841709/packages/test-runner-core/src/server/middleware/cacheMiddleware.ts#L12 ↩