Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K6 Browser adds no-cache headers #4165

Open
jgaalen opened this issue Jan 9, 2025 · 3 comments
Open

K6 Browser adds no-cache headers #4165

jgaalen opened this issue Jan 9, 2025 · 3 comments
Assignees
Labels

Comments

@jgaalen
Copy link

jgaalen commented Jan 9, 2025

I've noticed the K6 Browser adds the no-cache headers to all requests, preventing the browser from using a cache. This means that subsequent actions/pages can't use the cache. The problem with this, is that objects are retrieved too many times and page load times aren't realistic.

When K6 Browser clicks around, it should not keep doing the same requests to the same objects, that makes no sense. I couldn't find a way to disable this way of 'disabling' the local cache. I thought every browser context has it's own context -> cache/cookies so I don't see a reason why cache should be disabled.

@olegbespalov
Copy link
Contributor

Sounds reasonable to me to make no-cache behavior at least configurable 👍

@ankur22 @inancgumus what do you think?

@ankur22
Copy link
Contributor

ankur22 commented Jan 15, 2025

@jgaalen thanks for reaching out with a feature request. Currently, as you have worked out, there is no way to cache objects/cookies. We are aware of this limitation and are working on triaging this work. I can't say when the implementation work will start.


From a quick search it looks like there are several ways we could attempt to cache or store the state of the website:

  1. When we implement page.route it will disable the request/response cache.
  2. We could look into a persistent browserContext which will persist the whole user directory.
  3. browserContext.storageState, which will save the cookies and localStorage of the current browserContext, but not the session.
  4. No APIs to save the session, but it can be evaluated on and saved.

@jgaalen
Copy link
Author

jgaalen commented Jan 15, 2025

@jgaalen thanks for reaching out with a feature request. Currently, as you have worked out, there is no way to cache objects/cookies. We are aware of this limitation and are working on triaging this work. I can't say when the implementation work will start.

From a quick search it looks like there are several ways we could attempt to cache or store the state of the website:

  1. When we implement page.route it will disable the request/response cache.
  2. We could look into a persistent browserContext which will persist the whole user directory.
  3. browserContext.storageState, which will save the cookies and localStorage of the current browserContext, but not the session.
  4. No APIs to save the session, but it can be evaluated on and saved.

Thank you for your reply and options. Not sure if it was clear, but the main request is, to have caching available within a single iteration. It is a nice to have to have a predefined cache, so it is possible to simulate revisits of users rather than always simulate new users (which will have a much higher unrealistic strain on the backends)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants