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

fix(qwik-city): Prevent unexpected caching for q-data.json more #6808

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

genki
Copy link
Contributor

@genki genki commented Aug 19, 2024

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests / types / typos
  • Infra

Description

I have introduced the fetch options to avoid caching for q-data.json when opts.cacheClear is set (at #6797), but it was not enough.
As the loadClientData function manages caching by itself using CLIENT_DATA_CACHE, there is no need to use browser cache mechanism.
Or rather if they are used unexpectedly, it means we fetch not fresh q-data.json that may have been already changed in server side.
So I expanded the use of that options to the cases other than the opts.cacheClear is set, to all GET request as well.

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have ran pnpm change and documented my changes
  • I have made corresponding changes to the Qwik docs
  • Added new tests to cover the fix / functionality

@genki genki requested a review from a team as a code owner August 19, 2024 08:38
Copy link

changeset-bot bot commented Aug 19, 2024

🦋 Changeset detected

Latest commit: 2b5f6c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@builder.io/qwik-city Minor
eslint-plugin-qwik Minor
@builder.io/qwik Minor
create-qwik Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Aug 19, 2024

Open in Stackblitz

npm i https://pkg.pr.new/@builder.io/qwik@6808
npm i https://pkg.pr.new/@builder.io/qwik-city@6808
npm i https://pkg.pr.new/eslint-plugin-qwik@6808
npm i https://pkg.pr.new/create-qwik@6808

commit: 2b5f6c5

Copy link
Contributor

github-actions bot commented Aug 19, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 2b5f6c5

Copy link
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a changeset?

So if I understand correctly, you should always deny caching because the client-side caching happens inside Qwik and not in the browser, right?

@@ -30,15 +30,5 @@ export const QWIK_BINDING_MAP = {
"platformArchABI": "qwik.win32-x64-msvc.node"
}
]
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change should be reverted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it. I don't know why this change has happened

@genki
Copy link
Contributor Author

genki commented Sep 9, 2024

@wmertens I have added the changeset.
Yes, the fetched client data should be always fresh one if the cached one is missing in the Qwik City.

@genki
Copy link
Contributor Author

genki commented Sep 10, 2024

I think if the contents of q-data.json is constant for all visitors, the server side caching is meaningful.
Browser cache is mostly no meaning but may be effective when the visitor is opening many tabs.
If there is a way to specify the scope that the q-data.json spatiotemporally being same value, we can put the scope id to the URL search params as the cache buster for invalidating the server side and browser cache. This is ideal.

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

Successfully merging this pull request may close these issues.

2 participants