Giter VIP home page Giter VIP logo

purge-static's Introduction

purge-static PyPI PyPI - Format PyPI - Python Version

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

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:

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:

{"api_token": "myverysecretapitoken"}

For legacy API keys, use this instead:

{
    "email": "[email protected]",
    "api_key": "myverysecretapikey"
}

Then, you can invoke purge-static:

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.

purge-static's People

Contributors

quantum5 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

dvershinin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.