@superherocheesecake/cache-validator

1.0.2 • Public • Published

Cache Validator

This CLI util will validate CDN/cache settings on a website, by default using the standard Superhero Cheesecake caching strategy patterns for CloudFront.

The tool will load the user specified url, render the webpage, and execute javascript. Then individual requests will be checked against the cache settings as specified in the config.

Get the tool (installs globally)

npm i @superherocheesecake/cache-validator -g

Basic Usage

validate-cache --url https://superherocheesecake.com

Options

url

default is https://superherocheesecake.com

--url=url

cachePatterns

It is possible to specify a custom cache pattern config to allow custom cache settings and CDN provider to be validated. This parameter requires a path to a config JSON file.

--cachePatterns=cachePatternsConfigJSON

Custom configuration

The default cache pattern config file for the validator looks like this:

{
    "patterns": [
        {
            "name" : "Main document",
            "path" : "/",
            "requiredHeaders": ["cache-control", "x-cache"],
            "requiredValues" : {
                "cache-control": {
                    "maxAge": "1800"
                },
                "x-cache" : "Hit from cloudfront" 
            }
        },
        {
            "name" : "API's",
            "path" : "/api",
            "requiredHeaders": ["cache-control"],
            "requiredValues" : {
            }
        },
        {
            "name" : "Static assets",
            "path" : "/static",
            "requiredHeaders": ["cache-control", "x-cache"],
            "requiredValues" : {
                "cache-control": {
                    "maxAge": "31536000"
                },
                "x-cache" : "Hit from cloudfront" 
            }
        },
        {
            "name" : "Content",
            "path" : "/content",
            "requiredHeaders": ["cache-control", "x-cache"],
            "requiredValues" : {
                "cache-control": {
                    "maxAge": "3600"
                },
                "x-cache" : "Hit from cloudfront"                
            }
        }   
    ] 
}

Readme

Keywords

none

Package Sidebar

Install

npm i @superherocheesecake/cache-validator

Weekly Downloads

6

Version

1.0.2

License

ISC

Unpacked Size

9.55 kB

Total Files

7

Last publish

Collaborators

  • n0cha
  • edwardmediamonks
  • wesleysmulders
  • ksawery.mediamonks
  • vandenhork25
  • johanholwerda
  • renedrie
  • kristemmerman123
  • odin.schwartz
  • bolex222
  • coco_g
  • frontend_shcc
  • alfred_shcc
  • carinashcc
  • lukasfeitsma
  • jameswhite
  • raul.roman
  • jaak.kivinukk