cache-refresh

1.0.7 • Public • Published

Cache Refresh

This package will update version numbers in query strings in HTML to prevent the browser from caching certain files.

Configuration

The simplest way to configure this is to create a .refreshconfig file in the root directory.

.refreshconfig

There are three parameters for configuration.

Parameter Description Type Required
inputFile File that contains paths to Script / CSS file(s) string Yes
scriptFile File name(s) for Script / CSS file(s) string or Array Yes
outputFile Output file, same as inputFile if empty string No

Example #1:

This example represents a configuration with one file to update the versions on.

In this example, Cache Refresher will search "myFile.html" for instances of "myScript.js" and append a query string (?v=1). If it already has a query string for the version, it will add 1 to it, it will output to a file called "differentFile.html"

{
    "inputFile": "myFile.html",
    "scriptFile": "myScript.js",
    "outputFile": "differentFile.html"
}

Example #2:

This example represents a configuration with multiple files to update the versions on.

In this example, Cache Refresher will search "myFile1.html" and "myFile2.html" for instances of "myScript.js" and append a query string (?v=1). If it already has a query string for the version, it will add 1 to it, "myFile1.html" will output to a file called "differentFile.html", but "myFile2.html" will be replaced with the new file with updated version numbers.

[
    {
        "inputFile": "myFile1.html",
        "scriptFile": "myScript.js",
        "outputFile": "differentFile.html"
    },
    {
        "inputFile": "myFile2.html",
        "scriptFile": "myScript.js"
    }
]

Example #3:

This example represents a configuration with one file to update the versions on with multiple script files.

In this example, Cache Refresher will search "myFile.html" for instances of "myScript.js", "myStyle.css", "myStyle2.css", "anotherScript.js" and append a query string (?v=1). If it already has a query string for the version, it will add 1 to it. "myFile.html" will be replaced with the new file with updated versions.

{
    "inputFile": "myFile.html",
    "scriptFile": [
        "myScript.js",
        "myStyles.css",
        "myStyles2.css",
        "anotherScript.js"
    ]
}

Example #4:

This example represents a configuration with multiple files to update the versions on with multiple script files.

In this example, Cache Refresher will search "myFile1.html" for instances of "myScript.js" and will search "myFile2.html" for instances of "myScript.js", "myStyles.css", "myStyles2.css", and "anotherScript.js". It will append a query string (?v=1) to these instances. If it already has a query string for the version, it will add 1 to it, "myFile1.html" will output to a file called "differentFile.html", but "myFile2.html" will be replaced with the new file with updated version numbers.

[
    {
        "inputFile": "myFile1.html",
        "scriptFile": "myScript.js",
        "outputFile": "differentFile.html"
    },
    {
        "inputFile": "myFile.html",
        "scriptFile": [
            "myScript.js",
            "myStyles.css",
            "myStyles2.css",
            "anotherScript.js"
        ]
    }
]

Readme

Keywords

none

Package Sidebar

Install

npm i cache-refresh

Weekly Downloads

1

Version

1.0.7

License

ISC

Unpacked Size

271 kB

Total Files

42

Last publish

Collaborators

  • tyamz