Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quantum5/purge-static
Find changed static files, show their URLs, and optionally purge them for you on your CDN.
https://github.com/quantum5/purge-static
cdn cdn-cache-invalidation cloudflare static-site
Last synced: 3 months ago
JSON representation
Find changed static files, show their URLs, and optionally purge them for you on your CDN.
- Host: GitHub
- URL: https://github.com/quantum5/purge-static
- Owner: quantum5
- License: mit
- Created: 2018-12-03T23:45:03.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-28T03:44:52.000Z (about 3 years ago)
- Last Synced: 2024-09-17T20:18:12.480Z (5 months ago)
- Topics: cdn, cdn-cache-invalidation, cloudflare, static-site
- Language: Python
- Homepage: https://pypi.org/project/purge-static/
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `purge-static` [![PyPI](https://img.shields.io/pypi/v/purge-static.svg)](https://pypi.org/project/purge-static/) [![PyPI - Format](https://img.shields.io/pypi/format/purge-static.svg)](https://pypi.org/project/purge-static/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/purge-static.svg)](https://pypi.org/project/purge-static/)
`purge-static` is a tool to find changed static files, show their URLs,
and optionally purge them for you on your CDN, such as Cloudflare.With `purge-static`, you can enable aggressive caching for your static
site on your CDN, caching the entire site on the CDN edge. When you update
your site, you simply need to use `purge-static` to purge only the changed
files.`purge-static` uses the SHA256 hash of files to determine if they changed.
## Installation
```
pip install purge-static
```## Example Invocation
```sh
purge-static -d /path/to/my/webroot -u https://example.com
```If your webroot is not writable, you can select a different path to write
the hash store with `--store /path/to/a/file/to/store/hashes`.This example ignores all `.gz` files, since they are only used for `nginx`'s
`gzip_static` module, as well as all files with hash already in the name:```sh
purge-static -d /path/to/my/webroot -u https://example.com \
-i '.*\.gz$|.*-[0-9a-f]{64}\.'
```For more detailed description of the arguments, run `purge-static --help`.
## Cloudflare
To use Cloudflare, you will need to create a credentials file:
```json
{"api_token": "myverysecretapitoken"}
```For legacy API keys, use this instead:
```json
{
"email": "[email protected]",
"api_key": "myverysecretapikey"
}
```Then, you can invoke `purge-static`:
```sh
purge-static -d /path/to/my/webroot -u https://example.com \
--cloudflare -c /path/to/my/credentiails -z mycloudflarezoneid
```Note that `-z` takes the Cloudflare zone ID as 32 hex digits.