This is an experimental project at the moment, and has not been tested on production yet! Use at your own discretion!
This is the repository for the lib_dynamiccaching plugin. This plugin adds dynamic page caching, including the following capabilities:
- Dynamic stock based cache timings, based on Active Data (Sales Velocity) (PDP & Lister Page)
The lib_dynamiccaching plugin requires the app_storefront_base cartridge. In your cartridge path, include the cartridges in the following order:
plugin_dynamiccaching:lib_dynamiccaching:app_storefront_base
- Clone this repository. (The name of the top-level folder is lib_dynamiccaching.)
- In the top-level plugin_gtm folder, enter the following command:
npm install
. (This command installs all of the package dependencies required for this plugin.) - In the top-level lib_dynamiccaching folder, enter the following command:
npm run uploadCartridge
For information on Getting Started with SFRA, see Get Started with SFRA .
You can find the config file dynamic-caching.json
in the lib_dynamiccaching cartridge.
{
"inventoryLevelsChangeOften": false,
"activeHoursInDay": 14,
"minCacheTime": 1,
"maxCacheTime": 24,
"promotionInfluence": 0.5,
"modifiers": {
"day": 1,
"week": 1,
"month": 1
}
}
With this configuration file, you can manipulate the fallback cache time when Active Data is missing or unavailable.
- true: Your inventory changes often, possibly every hour, which means a short caching period is required if we can not take active Data into account.
- false: Your inventory only gets imported once a day
Default value: false
The standard Active Data keeps into account the total 24 hours of the day. But I have been told that people tend to sleep during some of these hours. This setting changes the 24 hours calculation to the specified amount of hours.
Default value: 14
The shortest caching time that you want to allow. And it is also used to choose a fallback value if Active Data is unavailable.
Default value: 1
The longest caching time that you want to allow. And it is also used to choose a fallback value if Active Data is unavailable.
Default value: 24
When a promotion has been activated on the current day, by which amount should the caching time be reduced.
e.g. The calculation deems that based on Active Data 8 hours caching should be good, but since a promotion was activated today 4 hours might be better.
Minimum: 0
, Maximum 1
Default value: 0.5
(50%)
By default, all periods in Active Data carry the same weight in the calculation. You can use this configuration to modify that behavior.
Default value: 1
The product details page has only been overwritten to add a data-attribute on the main <div>
for debugging purposes.
A custom cache is used to improve performance when filtering, sorting, ... on search results.
An added advantage: When a product is viewed on search results first, the cache timing for the PDP will already have been calculated and cached!
Use the provided NPM scripts to compile and upload changes to your sandbox.
npm run lint
- Execute linting for all JavaScript and SCSS files in the project.
npm run watch
- Watches everything and recompiles (if necessary) and uploads to the sandbox. Requires a valid dw.json
file at the root that is configured for the sandbox to upload.