Suppose the content editors of your application are preparing content of the application in a Rich Text editor where they are adding links to other pages (internal as well as external). Now you want to control the clicks on those links for various reasons like:

  1. Logging the link clicks to an analytics tool like Google Analytics or Omniture etc.
  2. Restrict the links pointing to some specific domains which may contain virus or for some other moderation purpose
  3. Convert some links to XHR and use those to pull/show data on same…

Disclaimer: You might notice that I will write many sentences in philosophical way which could be written otherwise.

Story for no reason at all

I was 11 years old when I first touched a computer. It was Class 7 in a small school in my village and computer was introduced as an additional (optional) subject. I was super excited to know the magical machine that I had seen only on TV before.

It was the year I spent playing ‘Dangerous Dave’ game. At the same time Microsoft launched Windows 95, Bill Gates turned focus on Web, US air force introduced drone, Sony released play station, Sun…

Sometime there is a need to cache the GET requests so that browser doesn’t have to hit server to fetch same data when same service is invoked serially or in parallel. We will implement HttpInterceptor interface of Angular to solve the purpose.

Step 1: Create a service to add URIs for caching

First of all we will create a service that will be used to register the URIs to be cached when we implement the HttpInterceptor.

Step 2: Add CacheRegistrationService to main module providers

Next step is to make this service available via providers of the application module

Step 3: Implementing HttpInterceptor

Now, let’s create our class to cache the URIs.

This will cache only GET requests whose URIs…

Vikesh Mittal

User Interface Architect | Passionate about Micro-frontends | Angular |

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store