This repository was archived by the owner on May 28, 2023. It is now read-only.
Output cache with tagging and cache forwarding added #332
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.
Output Cache
To limit the number of Elastic queries we've introduced Output API Cache (disabled by default).
The output cache is set by the following
config/local.jsonvariables:Dynamic tags
The dynamic tags config option:
useOutputCacheTagging- if set totrue, Vue Storefront is generating the special HTTP HeaderX-VS-Cache-TagsCache tags are assigned regarding the products and categories that are used on the specific page. A typical
X-VS-Cache-Tagstag looks like this:The tags can be used to invalidate the Varnish cache, if you're using it. Read more on that.
Redis
If both
useOutputCacheanduseOutputCacheTaggingoptions are set totrue, Vue Storefront is using output cache stored in Redis (configured in the redis section of the config file). Cache is tagged with dynamic tags and can be invalidated using a special webhook:An example call to clear all pages containing specific product and category:
curl http://localhost:8080/invalidate?tag=P1852,C20An example call to clear all product, category, taxrule and attribute entities
curl http://localhost:8080/invalidate?tag=product,category,taxrule,attributeCLI cache clear
You can manually clear the Redis cache for specific tags by running the following command:
npm run cache clear npm run cache clear -- --tag=product,category npm run cache clear -- --tag=P198 npm run cache clear -- --tag=*Available tag keys are set in the
config.server.availableCacheTags(by default:"product", "category", "home", "checkout", "page-not-found", "compare", "my-account", "P", "C")Dynamic cache invalidation:
All the official Vue Storefront data indexers including magento1-vsbridge-indexer, magento2-vsbridge-indexer and mage2vuestorefront support the cache invalidation. If the cache is enabled in both API and Vue Storefront frontend app, please make sure you are properly using the
config.server.invalidateCacheForwardUrlconfig variable as the indexers can send the cache invalidate request only to one URL (frontend or backend) and it should be forwarded. Please check the default forwarding URLs in thedefault.jsonand adjust thekeyparameter to the value ofserver.invalidateCacheKey.For
mage2vuestorefrontplease do use the proper ENV variables:For
magento1-vsbridge-indexerandmagento2-vsbridge-indexerplease do use the proper settings in the Magento admin panel.Note: Please note that
key=SECRETKEYshould be equal tovue-storefront/config/local.jsonvalue ofserver.invalidateCacheKey