Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Create client side cache using ES6 Proxy

With the release of ES6 (ECMAScript 2015) they added the new Proxy feature. It lets you create a middleware when doing changes to a object. With the release of ES6 (ECMAScript 2015) they added the new Proxy feature. It lets you create a middleware when doing changes to a object. We will use this to build a simple cache helper for the client side. We will use sessionStorage to store the data so we don't have to care about invalidation. // The name of the sessionStorage item. const sessionKey = 'cachedData'; // Get stored items const sessionItems = sessionStorage.getItem(sessionKey); // Parse the stringified items if it exists else create a empty object let cachedItems = sessionItems ? JSON.parse(sessionItems) : {}; const handler = { // This trap (function) will be run each time we are setting the property values set (target, key, value) { // Add the new… Read More
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web