1.0.7 • Published 4 years ago

cache-refresh v1.0.7

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

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.

ParameterDescriptionTypeRequired
inputFileFile that contains paths to Script / CSS file(s)stringYes
scriptFileFile name(s) for Script / CSS file(s)string or ArrayYes
outputFileOutput file, same as inputFile if emptystringNo

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"
        ]
    }
]
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago