Skip to content

feat(composables): add opt-in cacheableReads for cacheable GET Store API requests#2473

Merged
Maciek Kucmus (mkucmus) merged 4 commits into
mainfrom
feat/opt-in-get-requests
Jun 8, 2026
Merged

feat(composables): add opt-in cacheableReads for cacheable GET Store API requests#2473
Maciek Kucmus (mkucmus) merged 4 commits into
mainfrom
feat/opt-in-get-requests

Conversation

@mkucmus

@mkucmus Maciek Kucmus (mkucmus) commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What

Opt-in cacheableReads flag that routes anonymous Store API reads through their cacheable GET variants (criteria via _criteria) instead of POST.

Off by default - fully backwards compatible.

related issue to enable readProductListingGet operation: shopware/shopware#17204

Why

POST reads can't be HTTP/CDN-cached and trigger a CORS preflight. The GET variants return the same data, are cacheable, and skip the preflight.

Enable

// nuxt.config.ts
shopware: { cacheableReads: true }
// non-Nuxt: createShopwareContext(app, { cacheableReads: true })

@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontends-starter-template-extended Ready Ready Preview, Comment Jun 8, 2026 8:22am
frontends-vue-starter-template Building Building Preview, Comment Jun 8, 2026 8:22am
old-frontends-demo Ready Ready Preview, Comment Jun 8, 2026 8:22am
shopware-frontends-docs Ready Ready Preview, Comment Jun 8, 2026 8:22am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in cacheableReads flag to route selected Store API read operations through cacheable GET endpoints (using compressed _criteria) instead of POST, wiring the flag through Nuxt runtime config and Shopware context so composables/templates can switch behavior without changing public composable APIs.

Changes:

  • Add cacheableReads to the Nuxt module options + plugin context creation, and expose it via useShopwareContext().
  • Update multiple composables (and a couple templates) to use *Get get Store API operations and _criteria: encodeForQuery(criteria) when cacheableReads is enabled.
  • Extend/adjust unit tests to cover both POST (default) and GET (opt-in) paths, and add a changeset entry.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
templates/vue-starter-template/app/components/form/SalutationSelect.vue Switch salutation load to GET variant when cacheableReads is enabled.
templates/vue-demo-store/app/pages/wishlist.vue Use _criteria + GET product read when cacheableReads is enabled.
packages/nuxt-module/src/index.ts Document and expose cacheableReads on ShopwareNuxtOptions.
packages/nuxt-module/plugin.ts Pass cacheableReads from runtime config into createShopwareContext.
packages/composables/src/useUser/useUser.ts Use GET + _criteria for country/salutation lookups when enabled.
packages/composables/src/useUser/useUser.test.ts Add/adjust tests for POST default vs GET opt-in behavior.
packages/composables/src/useShopwareContext/useShopwareContext.ts Add cacheableReads to the context type and return value.
packages/composables/src/useSalutations/useSalutations.ts Use salutation GET read when enabled.
packages/composables/src/useProductSearch/useProductSearch.ts Use product detail GET + _criteria when enabled.
packages/composables/src/useProductSearch/useProductSearch.test.ts Add GET-path test coverage for cacheableReads.
packages/composables/src/useProductConfigurator/useProductConfigurator.ts Use product GET + _criteria when enabled for variant lookup.
packages/composables/src/useNavigationSearch/useNavigationSearch.ts Use SEO URL GET + _criteria when enabled.
packages/composables/src/useNavigationSearch/useNavigationSearch.test.ts Add GET-path test coverage for cacheableReads.
packages/composables/src/useNavigation/useNavigation.ts Use navigation GET + _criteria (and depth/buildTree as query params) when enabled.
packages/composables/src/useNavigation/useNavigation.test.ts Add GET-path test coverage for cacheableReads.
packages/composables/src/useInternationalization/useInternationalization.ts Use languages GET read when enabled.
packages/composables/src/useCountries/useCountries.ts Use countries GET + _criteria when enabled.
packages/composables/src/useCategorySearch/useCategorySearch.ts Use category list GET + _criteria when enabled for advancedSearch.
packages/composables/src/useCategorySearch/useCategorySearch.test.ts Add GET-path test coverage for cacheableReads.
packages/composables/src/createShopwareContext.ts Add cacheableReads option and store it on the Shopware context.
.changeset/post-to-get-cacheable-reads.md Publish-facing changeset describing the new opt-in behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/composables/src/useShopwareContext/useShopwareContext.ts Outdated
Comment thread packages/nuxt-module/src/index.ts Outdated
Comment thread .changeset/post-to-get-cacheable-reads.md Outdated
Comment thread packages/composables/src/useInternationalization/useInternationalization.ts Outdated
@mkucmus Maciek Kucmus (mkucmus) merged commit 22611e5 into main Jun 8, 2026
10 checks passed
@mkucmus Maciek Kucmus (mkucmus) deleted the feat/opt-in-get-requests branch June 8, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants