Fasterize is a kind of super proxy that can optimize web page content on the fly. Our solution works for both static and dynamic pages.
In this article, we’ll look at how we’ve optimized our engine for these dynamic pages.
Not-so-dynamic dynamic pages
Our initial observation: some of the non-cacheable dynamic pages are in fact identical and are therefore re-optimized unnecessarily.
For example, the page of an e-commerce store is identical from one navigation to the next until the customer has filled the shopping cart. This means that the page can be 90% of the time the same, and 10% of the time customized according to the user session.
Step one: measure the impact of the phenomenon
The first action we took was to measure the extent of the phenomenon by calculating a hash of the content of each server response. We found that 30% of responses to dynamic pages were identical! And that we could therefore save 30% on engine optimizations!
We then looked at the realistic retention time required to maintain an optimized version of the page.
Keeping an optimized page for one minute seems to be sufficient for over 99% of pages.
Step two: implement the algorithm
At the end of a page’s optimization, the engine keeps a copy for one minute, and this copy is associated with the hash of the original response. So, before optimizing, the engine checks that it hasn’t already optimized the page in the previous minute. If it has, the engine serves the already optimized version and avoids further optimization. This reduces optimization time on the page by around 60ms, taking the load off the engine.
One limitation we have observed is that some pages are artificially dynamic.
In fact, the content of the page may differ because a comment containing the date and time the page was generated or a random parameter is added to the URLs of static resources (which, by the way, also breaks the HTTP cache mechanism).
Dynamic Cache therefore enables our optimization engine to reduce the overhead it can add when optimizing a page. It’s important to note that this overhead mainly impacts the TTFB (Time To First Byte) of the page, and that the optimizations applied to the page can save much more than a few tens of milliseconds in overall loading time.