# cache-refresh

> Attempts to prevent browser caching by adding '?v=' to the end of specified filenames in specified files.

Latest version **1.0.7** (published 2020-08-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install cache-refresh
pnpm add cache-refresh
yarn add cache-refresh
bun add cache-refresh
```

Provides the command `cache-refresh`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-08-06 |
| First published | 2020-08-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 265.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Thomas Yamakaitis |
| Maintainers | tyamz |

## Links

- npm: https://www.npmjs.com/package/cache-refresh
- npm.io page: https://npm.io/package/cache-refresh

## Recent versions

- 1.0.7 (latest) — 2020-08-06
- 1.0.6 — 2020-08-06
- 1.0.5 — 2020-08-06
- 1.0.4 — 2020-08-06
- 1.0.3 — 2020-08-06
- 1.0.2 — 2020-08-06
- 1.0.1 — 2020-08-06
- 1.0.0 — 2020-08-06

## README

# 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"

```json
{
    "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.

```json
[
    {
        "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.

```json
{
    "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.

```json
[
    {
        "inputFile": "myFile1.html",
        "scriptFile": "myScript.js",
        "outputFile": "differentFile.html"
    },
    {
        "inputFile": "myFile.html",
        "scriptFile": [
            "myScript.js",
            "myStyles.css",
            "myStyles2.css",
            "anotherScript.js"
        ]
    }
]

---
_Source: https://npm.io/package/cache-refresh · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
