Coder Social home page Coder Social logo

rack-cache-smash's Introduction

rack-cache-smash

rack-cache-smash is a Rack middleware to cache bust every CSS and JS asset request, intended for development environments only and not recommended for production.

Cache busting happens by modifying all HTML responses that contain paths to JS and CSS files. These file paths are appended with a timestamp query string parameter to force browsers to re-download the files for every single page load as they always have a unique URL.

Admittedly, this is a sledgehammer of a middleware to overcome those browser caching issues that sometimes arise during development. I don't advise using it in production, and I doubt that you want to.

At the time of writing this, I'm using rack-cache-smash during development to overcome a problem in iOS 7.0.2 where incomplete asset downloads seem to be cached and some weirdness I've seen in IE10 on Windows 8 with assets, 304 Not Modified responses, and SSL.

Installation

Add the rack-cache-smash gem to the development group in your application's Gemfile:

group :development do
    ...
    gem 'rack-cache-smash'
end

And then execute:

$ bundle

For Rails apps, add this line to config/application.rb:

config.middleware.use(Rack::CacheSmash)

For Rack apps that don't use Rails, then place Rack::CacheSmash earlier in your middleware stack than the middleware(s) that generates response HTML.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Run tests (rake test)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

Releasing a new gem

  1. Update pre-release version to the release version in lib/rack-cache-smash/version.rb, e.g. '1.0.1.pre' becomes '1.0.1'
  2. Update CHANGELOG.md
  3. Tests pass? (rake test)
  4. Build the gem (rake build)
  5. Release on rubygems.org (rake release)
  6. Update version to the next pre-release version in lib/rack-cache-smash/version.rb, e.g. '1.0.1' becomes '1.0.2.pre'

rack-cache-smash's People

Contributors

eliotsykes avatar

Watchers

 avatar James Cloos avatar  avatar

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.