Code Monkey home page Code Monkey logo

heroku_asset_cacher's Introduction

Heroku Asset Cacher

This plugin will override the caching options of Rails helpers: javascript_include_tag and stylesheet_link_tag. It will instruct them to place their cached assets into the Rails /tmp directory, the only writeable directory in Heroku. It then adds some Rack middleware to route requests for those files to the /tmp directory.

Install

script/plugin install http://github.com/mgomes/heroku_asset_cacher.git

Usage

This plugin will only override the requests for all.js and all.css. So please use the convention of naming your cached JS and CSS assets: all.js and all.css, respectively. (these are the default naming conventions). Here is an example:

javascript_include_tag :all, :cache => true
stylesheet_link_tag :all, :cache => true

Or you can specify individual files to cache, as such:

javascript_include_tag 'jquery', 'jquery.tooltip', :cache => true
stylesheet_link_tag 'main_design', 'secondary_design', :cache => true

Files that are not included in the all.js or all.css bundle will still be served from their original directories.

Clearing the cached assets

You can run the following rake task on Heroku to regenerate your cached assets:

rake asset_cache:clear

Testing

To run the test suite:

rake test

To try out Heroku Asset Cacher in development, you can set the following option in environment.rb:

ActionController::Base.perform_caching = true

Previous Art

This plugin is based off of the work by Matthew Savage in his Heroku Asset Packager plugin.

Author

Copyright © 2010 Mauricio Gomes, released under the MIT license

heroku_asset_cacher's People

Contributors

mgomes avatar zeke avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.