Code Monkey home page Code Monkey logo

cache-buster's Introduction

logo image

Cache Buster

May your cache live long and prosper!

Documentation CI (Linux) dependency status
codecov

What is cache busting?

To optimise network load time, browsers cache static files. Caching greatly improves performance but how do you inform browsers to invalidate cache when your files have changed?

Cache busting is a simple but effective solution for this issue. There are several ways to achieve this but the way this library does this is by changing file names to include the hash of the files' contents.

So if you have bundle.js, it will become bundle.<long-sha256-hash>.js. This lets you set a super long cache age as, because of the file names changing, the path to the filename, too, will change. So as far as the browser is concerned, you are trying to load a file that it doesn't have. Pretty neat, isn't it?

Features

  • SHA-256 based name generation during compile-time
  • Processes files based on provided MIME filters
  • Exclude certain files from processing based on file extensions and/or file paths
  • Exposes modified names to program during runtime
  • Route prefixes(optional)

Usage:

Add this to your Cargo.toml:

cache-buster = { version = "0.2", git = "https://github.com/realaravinth/cache-buster" }

Examples:

cache-buster's People

Contributors

realaravinth avatar

Watchers

 avatar

cache-buster's Issues

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.