Giter Site home page Giter Site logo

lib_dynamiccaching's Introduction

lib_dynamiccaching: Storefront Reference Architecture (SFRA)

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)

Sales Velocity

Cartridge Path Considerations

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

Getting Started

  1. Clone this repository. (The name of the top-level folder is lib_dynamiccaching.)
  2. 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.)
  3. 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 .

Configuration

You can find the config file dynamic-caching.json in the lib_dynamiccaching cartridge.

Example

{
   "inventoryLevelsChangeOften": false,
   "activeHoursInDay": 14,
   "minCacheTime": 1,
   "maxCacheTime": 24,
   "promotionInfluence": 0.5,
   "modifiers": {
      "day": 1,
      "week": 1,
      "month": 1
   }
}

stockLevelsChangeOften

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

activeHoursInDay

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

minCacheTime

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

maxCacheTime

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

promotionInfluence

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%)

modifiers

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

Product Details Template

The product details page has only been overwritten to add a data-attribute on the main <div> for debugging purposes.

Cache debugging

Custom Cache

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!

img.png

Release management

NPM scripts

Use the provided NPM scripts to compile and upload changes to your sandbox.

Linting your code

npm run lint - Execute linting for all JavaScript and SCSS files in the project.

Watching for changes and uploading

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.

lib_dynamiccaching's People

Contributors

taurgis avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.