Search code examples
shopware6

Cache-Invalidation for products release date


I wonder how the internal shopware cache handles the products release date, because there are some things that are dependent on this field:

  1. Information on shipping in the storefront
  2. New-Badges/Flags that last x-days (depending on configuration) after the release date

Because you can set the releaseDate with minute-precision, how does shopware handle the invalidation of a product that...

  1. ... reached its release date to display the correct shipping information
  2. ... reached the date x-days after the release date to "remove" the new-flag

Solution

  • In general this is not handled by shopwares cache automatically and the cache is not invalidated automatic for those products.

    The main reason is that there is now real trigger/logic inside shopware that leads to this event where we can invalidate the cache, the trigger is "only" the passing of time.

    Also it is really hard to know where the new products will be displayed before their release date, it is not easy to calculate in which category pages e.g. a product will show up after it's release date, therefore you can't invalidate only those pages, but you would have to invalidate the whole cache.

    If you have a scenario where you rely heavily on the release dates for new products and heavily on caching you can go in the direction of having a "nightly" cache clear job that also warms up the most important pages for the cache. And then set the release date always to 00:00 or some time that is before the nightly cache clear job that on each day the newly released products will actually show up in your shop correctly.