Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

v0.5.3

Pre-release
Pre-release
Compare
Choose a tag to compare
@eneajaho eneajaho released this 18 Apr 17:01
· 47 commits to main since this release

Features

  • feat: Introduce RouteISRConfig interface for better type safety in route data

    How to use it?

    const routes: Rotues = [{
      path: 'home',
      component: HomeComponent,
      data: { revalidate: 0 } as RouteISRConfig // πŸ‘ˆ Add type to route data
    }];
  • feat: Added build id support

    What is it and why do we need it?

    The build id is a unique identifier that is generated for each build. It is used to invalidate the cache when a new build is deployed. So, when a new build is deployed, every page that will be requested will be server-rendered again and not served from the cache. This way, the users will always get the latest version of the application.

    Useful when you have an external cache handler like Redis.

    How to use it?

    To use it, you need to pass the build id to the ISRHandler constructor.
    Angular itself doesn't generate a build id. But we can generate it using the environment file.
    What we can do is to set field in the environment file called buildId and set it to: new Date().getTime(),.

    Ex. environment.ts:

    export const environment = {
      production: false,
      buildId: new Date().getTime() + '', // We need to convert it to string because the buildId is a string
    };

    This way we will have a unique build id for each build because the buildId will evaluated at build time.
    Then, we pass the build id to the ISRHandler constructor.

    Ex. server.ts:

    import { environment } from './src/environments/environment';
    
    const isr = new ISRHandler({
      .. other options
      buildId: environment.buildTimestamp // Pass the build id
    });
  • fix: Fixed a bug where the cache was not invalidated when the build id changed

Breaking changes:

  • ISROptions is being deprecated. Use CacheISRConfig instead.