feat: enable store api routes caching
1. Why is this change necessary?
For StoreAPI performance improvement, part of routes should support http caching.
2. What does this change do, exactly?
- Marks a number of StoreAPI routes for caching;
- Changes
CacheResponseSubscriberto add properCache-Controlheader to the StoreAPI routes marked for caching - Adds support of cache policies and allows to specify cache-control policies on global/local level.
3. Describe each step to reproduce the issue or behaviour.
- Enable caching using reverse proxy, like
http_cache:
reverse_proxy:
enabled: true
use_varnish_xkey: true
hosts:
# address to this varnish container or all varnish containers
- localhost
- Call endpoint that supports caching:
curl -i --location 'http://localhost:8000/store-api/category?limit=10' \
--header 'sw-access-key: YOUR_STOREFRONT_API_ACCESS_KEY'
4. Please link to the relevant issues (if any).
- closes https://github.com/shopware/shopware/issues/12391
5. Checklist
- [x] I have written tests and verified that they fail without my change
- [ ] I have created a changelog file with all necessary information about my changes
- [ ] I have written or adjusted the documentation according to my changes
- [x] This change has comments for package types, values, functions, and non-obvious lines of code
- [ ] I have read the contribution requirements and fulfilled them
| Warnings | |
|---|---|
| :warning: | You updated the shopware.yaml, please consider to update the config-schema.json |
part of routes should support http caching (at least on the reverse proxy side).
Just wondering it is not only reverse proxy cache, default symfony http caching should work as well correct?
📸 OpenAPI Snapshot
ℹ️ No changes detected compared to trunk
🔗 Base Branch Snapshot: https://explore-openapi.dev/view?project=shopware-store-api&snapshot=trunk
OpenAPI Snapshot
Project: shopware/store-api
No changes detected
Your OpenAPI schema is identical to the base branch (trunk).
Links:
All Project Snapshots · Base Branch Snapshot
Project: shopware/admin-api
No changes detected
Your OpenAPI schema is identical to the base branch (trunk).
Codecov Report
:x: Patch coverage is 80.47138% with 58 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 54.03%. Comparing base (62aa6ee) to head (692b168).
:warning: Report is 2 commits behind head on trunk.
:white_check_mark: All tests successful. No failed tests found.
Additional details and impacted files
@@ Coverage Diff @@
## trunk #12370 +/- ##
==========================================
+ Coverage 53.97% 54.03% +0.06%
==========================================
Files 3189 3193 +4
Lines 95733 95970 +237
==========================================
+ Hits 51669 51856 +187
- Misses 44064 44114 +50
| Flag | Coverage Δ | |
|---|---|---|
| phpunit-migration | 94.31% <ø> (ø) |
|
| phpunit-unit | 51.92% <80.47%> (+0.06%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.