HTTP Cache Rework #3299
Replies: 10 comments 10 replies
-
I am not sure if it a feasible idea, but it might be worth to think if one can specify the relevant cache keys for the edge side includes (ESI). For example imagine the categories shown in the navigation are by default not dependent on the customer group, so all customer groups could have the same navigation, but the language is still relevant. Furthermore one needs to think about how plugins can add their own cache keys for each ESI sub request, probably through an event, for example when the navigation should be dependent on the customer group. But it might also be that this adds to much complexity to the cache mechanism, just an idea :-) |
Beta Was this translation helpful? Give feedback.
-
In the past I encountered always two issues with the http-cache:
So I think it is important to really define invalidation rates on site-level (e.g. product detail pages, listing pages, navigation?,...), because there are a lot of shops out there where the listing needs to have a high hit-rate, but it is nearly impossible to get a high cache-hit rate with 500.000 product detail pages. So I might want to have the listings cached for 12hours and the detail pages for 48hours or whatever. It would be also nice to differentiate between updates via API and invalidations because of time. I saw setups where it would be helpful to deactivate the automatic invalidations because of API updates and just use the timed-invalidations and vice versa. So I think it is important to have as much flexible as possible in the project to decide how to handle invalidations, because it highly depends on the project setup and the kpis of the shop. In addition to that it might also be good to define if a page should be cached. Please also keep our Cloud offering in mind, this might also be something our bigger customers need. The rule-evaluation without caching will work the same as before (e.g. in cart or with deactivated http-cache)? |
Beta Was this translation helpful? Give feedback.
-
Very nice. Make sure to add some framework or documentation how to fetch custom content via ajax which is easy to use, so that plugin vendors don't mess with the cache key |
Beta Was this translation helpful? Give feedback.
-
@shyim Thanks! Very nice ideas. We had already some of this optimizations in the project. Customer specific prices are loaded via ajax, also things like availability of the product. We also removed $context->getRuleIds() in buildCacheHash method. |
Beta Was this translation helpful? Give feedback.
-
I'm really looking forward to this as this will benefit using Shopware in a headless setup a lot! |
Beta Was this translation helpful? Give feedback.
-
@shyim Could you already roughly say with which version these changes could be played out? |
Beta Was this translation helpful? Give feedback.
-
Thank you for sharing!
|
Beta Was this translation helpful? Give feedback.
-
I am currently in the process of making my plugins compatible for 6.6 and have encountered a problem with caching. After a lot of debugging I finally found this discussion. What is the current status of the implementation? (6.6 RC-1; No Plugins) In my tests I have the problem that in |
Beta Was this translation helpful? Give feedback.
-
I see the advanced prices get limited by customer group? I would really like it! This would make any Rule-Validation for prices superfluous. |
Beta Was this translation helpful? Give feedback.
-
We implemented with only particular parts with 6.6:
We will come up with an updated Proposal for 6.7 with more details for Pricing, Context - Cart resolving, HTTP Cache |
Beta Was this translation helpful? Give feedback.
-
Context
Currently, the caching is implemented in store-api layer and therefore requires object caching
to be shared between default storefront and store-api.
On top of that layer, we have http caching in the storefront as full-page cache.
When a user is authenticated,
the http cache will be disabled due to the active context rules of the customer,
and only the object cache will be still used based on the context rules.
Additionally, external systems often update products and categories very frequently. Consequently, the cache is invalid most of the time.
tldr:
Decision
Only use HTTP Cache
We will remove most of the object caches in the store-api and move the caching to the http layer.
The object cache will be only used for caches,
which are necessary for almost all requests such as the base sales channel context cache.
This will help us to: reduce the complexity of our cache system, reduce the size of redis caches, reduce the number of cache keys.
HTTP Cache for store-api
As we will remove the object cache in the store-api layer, the store-api will be completely cached via http cache.
This will improve the performance of a majority of the store-api and reduce the load on the application and database server.
Improving Cache key hit-rate
We will simplify the Cache key permutation and remove most of the context rules from the cache key.
As a result, the cache key will only contain:
The cache compatible context rules are a subset of the context rules,
which are compatible with caching procedure as they only use a limited range of information (the list above).
To still support customer-specific pricing, we will load the prices with ajax request and replace them in the storefront.
Custom projects can still customize the cache key, by creating custom cookies and configuring them to be included in the cache-key or subscribe to a specific event.
Improving cache invalidation
Cache invalidations are a very expensive operation, so the goal is to reduce the number of invalidations.
So we enable the delayed cache invalidation by default and collect invalidations for a configured time frame
(default 1 hour) and then soft-purge only the cache.
The soft-purge will mark the cache as stale and will be refreshed on the next request,
so that the customers will always surf against the latest cache.
In some updates the cache invalidation will be forced and directly purged, for example when:
Also provide a dedicated header to clear the cache directly on API written:
Introduce ESI tags
To reduce the number of invalidations for isolated small changes, i.e: category changes invalidating the whole cache,
we introduce Edge Side Includes (ESI) tags and use them for the storefront header and footer.
The header and footer are the most common parts of the storefront and are mostly not changed,
but when they change only one cache entry will be invalidated and not the whole shop cache.
Consequences
Beta Was this translation helpful? Give feedback.
All reactions