Why would you want your product list to load faster? Time is arguably the most valuable resource, and saving as much time as possible is important so that we can spend it doing the things we love. Furthermore, top e-commerce websites—Amazon, Zara, and Lulus—are very efficient at saving customers’ time. Their product lists load very fast, allowing customers to browse quicker and make decisions faster. Because of these other websites, customers’ expectations are very high when they visit your less popular e-commerce site.
In fact, there is a term in the industry called Jakob’s Law:
“Users spend most of their time on other sites. This means that users prefer your site to work the same way as all the other sites they already know.”
Therefore, serving your product list quickly is important—it saves time and makes your store a more familiar place for online shoppers.
The Role of Caching
In order to serve your product list faster, there is a technique called caching, which allows product list data to be saved in memory instead of on the hard drive. This enables data to be retrieved and served significantly faster.
When the CPU communicates with RAM, it does so through a bus—essentially a pathway between the CPU and RAM. This pathway can transfer, for example, 64 bits per CPU cycle. If the product list is 128 bits in size, it would take 2 cycles. In contrast, the connection between the CPU and the hard disk may only transfer 8 bits per CPU cycle, meaning it would take 16 cycles to deliver the same amount of data. So, if a CPU had a speed of 1 cycle per second, it would take 2 seconds using caching and 16 seconds without caching.
Redis and Smart Caching
Redis is a popular tool used for caching. It provides an API to store data in RAM and offers many additional features, such as data invalidation, updating cache data, setting expiration times, and more.
I titled this post Smart Caching because you can cache your product list in different ways. You could cache the entire product list—paginated and filtered—or you could optimize caching by storing only the necessary data.
For example, product lists change based on seasons, sales dates, and product availability. They can also vary depending on the user’s location. Instead of caching multiple versions of the full product list (e.g., summer + BOGO + East Coast, fall + BOGO + West Coast, winter + BOGO + South, etc.), you can cache seasonal data, sales data, and location-specific data separately. This way, instead of storing many large, pre-generated lists, you dynamically generate them at runtime using cached fragments. This method reduces memory usage and improves performance.
Conclusion
Customers spend most of their time on websites that have invested heavily in optimizing the shopping experience. This translates to faster browsing and decision-making, allowing users to save time and focus on what they love. Redis enables this by serving data from a much faster storage medium (RAM) instead of a traditional hard drive.