Caching is an effective way to reduce load times. But it is often difficult to apply it to the web pages because of the personalization (counter of elements in the basket, banner of login, ...)
Faced with this problem, our webperf experts have looked for different methods to improve caching over the last 4 years.
Here is a little overview of the various cache solutions they have made available to you on Fasterize.
Caching static resources
The inevitable classic caching! No need to present it. It applies to all resources and static pages.
The Fasterize engine respects the HTTP Cache-Control header filled in by the origin. If it is missing or incorrect, it is possible to replace them from the dashboard. The engine allows a fine-tuning of caching by choosing whether the resource can be cached by the browser and / or a CDN.
We apply a segmentation of the hidden pages.
Thus, each cached page has different hidden versions: according to the browsers, the terminals or according to a specific cookie (we use the value of a cookie in our cache key).
Where to configure the classic cache from your Fasterize dashboard?
In configuration> caching
NB. If you opt for a CDN, pages and static resources will be served from there.
Caching dynamic pages
Caching static resources is one thing. Caching dynamic web pages is another.
In this part, we will see how to hide web pages that contain custom parts (what are called here dynamic pages).
We noticed two things on this type of page:
- Dynamic pages are not completely dynamic
Often, a page is dynamic only because some areas of the page are customized. The rest of the page, however, is common to different users.
2. Dynamic pages are not always dynamic
You've probably noticed it too: most of the time, non-cacheable dynamic pages are identical from one user to another. Pages are only customized when the user does a particular action.
Let's take the concrete example of an e-commerce site: the page is identical from one navigation to another as long as the customer has not filled his basket. Thus, the page can be the same 90% of the time or customized according to the user session the 10% of the time remaining.
In a previous study, we found that 30% of responses to dynamic pages were identical!
In this context, it is a shame to deprive oneself of the caching of these pages which are not always and / or not completely dynamic.
Following these two findings, our team of experts deployed 3 advanced cache techniques on Fasterize:
- Smart Cache
- The Cookie Less Cache
- The Dynamic Cache
The Smart Cache allows you to cache the static part of a dynamic page.
We identify the dynamic and static parts of a web page. Then, the static parts are hidden while the dynamic parts are asynchronously loaded in a second time. (It's a bit ajaxification of your pages!)
To set up the Smart Cache, a specific setting is necessary to discern the dynamic parts, static parts.
Where to configure the Smart Cache from your Fasterize dashbord?
Still in configuration> caching
The Cookie Less Cache
We started from the observation that many identical "dynamic" pages were served to anonymous users of a site. Indeed, as long as a user has not received a cookie, the content of the page does not change from another user without a cookie.
We then developed the less cache cookie or cache for cookie-free users. This allows us to distinguish between users who are "anonymous" for the site (ie without cookies) and known users of the site (with cookies).
We cache the pages served to anonymous users and then serve them from the same cache to the following anonymous users. Users identified by a cookie will receive the (custom) page from the original server.
Where to configure the Cookie Less Cache from your Fasterize dashboard?
Go to configuration> rules
Check "Cache non-cacheable pages for anonymous users"
There is an important difference to understand between the Smart Cache and the Cookie Less cache: the first, requires a fine configuration that now requires a custom setting (selection of dynamic blocks). The second can be activated automatically without setting.
The Dynamic Cache
At Fasterize, we optimize on-the-fly the HTML code of the pages. So, when we saw that 30% of the responses to dynamic pages were identical, we wanted to hide these identical pages, so as not to reapply the same optimizations continuously .. For that, we configured the engine so that the end of optimizing a page, it keeps a copy for a minute (this copy is associated with the hash of the original answer).
So before doing an optimization, the engine checks that it has not already optimized the page in the last minute. If so, the engine serves the already optimized version and avoids further optimization. This reduces approximately 60ms of optimization time on the page and relieves the engine.
Which cache to choose?
These different typologies of cache regularly bring the question "Which cache should I activate?"
It all depends of course on your pages. Here is the order of priority that we advise you to adopt:
Is it possible to use the classic cache? If no, can the setting of Smart Cache be possible? If no, can you activate Cookie Less Cache?
If finally the Cookie Less Cache is not active (the request has a cookie), the Dynamic Cache will be automatically used by our engine.