The Power of Caching in JavaScript | by jsmanifest | Jan, 2022

Data and caching go hand in hand for performance

Photo via ThisisEngineering RAEng on Unsplash

When Your site is indexed in Google search results, Googlebot takes a snapshot every time a bot crawls through your website. When it does, it keeps a “backup” of your website. This is called Google Cache.

In the modern world, offline experiences for users are more important than ever.

The power of spooling shines well at “rigging” things. The word “Faking” has a very bad connotation when used in the real world but in the context of the DOM it is a positive! The first goal (arguably) in web applications is to delight our users, and in faking good performance, you are actually helping the user feel that they are in good hands.

Users should not be forced to wait for images to load in order to feel at home on our pages. By using placeholder images, we can allow the user to have an instantly easy experience with our pages if we replace the larger images with something else (such as a tracked SVG) While Real download ends. We can either cache the actual image to be loaded immediately the next time the user visits or we can Dimensional cache Which enables us to instantly display something like a silhouette at an expected size while it is being loaded.

Lazy loading is a common term in web development. It is a useful strategy that requests data for the user’s customer only when needed. Caching can help speed up slow loading if we cache resources it will be I asked when the time came. This is an import concept because Much The user agent never requests the data in web applications. Lazy loading helps you think about what needs to be cached so that it is only consumed when asked. You have likely interacted with an element on a web page using this concept.

We previously talked about service workers and it is worth noting here that this is where they really shine in faking a great performing app for your users.

We can make our functions process data faster over time by caching their results which can effectively become a performance boost in our applications.

  1. Save frequently accessed data that we can retrieve for later use when time-consuming or costly operations are no longer necessary. Users are important, so we also need to consider refreshing the cache periodically so that they can see the latest information.
  • Gatsby caches JSON objects which are captured in later builds in order to make the build process faster
  • SWR takes advantage of an HTTP cache invalidation strategy called state during revalidation to provide fast responses with the promise of first-hand data
  • Chrome V8 engine stores code compiled in three stages which is fast and efficient

And that ends this post! Hope you found this helpful and look forward to more in the future!

Leave a Comment