Skip to content

Rails plugin for loading CDN content locally when not connected to the Internet.

License

Notifications You must be signed in to change notification settings

alexreisner/local_assets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocalAssets

LocalAssets facilitates loading of assets normally served by various content delivery networks (CDNs) from local sources in development so your site loads faster, and works even when you don’t have an Internet connection (eg, on an airplane).

To set up a local CDN mirror, see: github.com/alexreisner/cdn_mirror

Rails

Add the gem to your Gemfile. Then add the following to your config/environments/development.rb file:

config.middleware.use "Rack::LocalAssets", {
  "//ajax.googleapis.com/ajax/libs/" => "//localhost/cdn_mirror/google/"
}

The configuration hash should contain any URL fragments that should be replaced with local alternatives in the development environment. The above example is for assets normally served by Google’s CDN.

Sinatra

require 'local_assets'

use Rack::LocalAssets, {
  "//ajax.googleapis.com/ajax/libs/" => "//localhost/cdn_mirror/google/"
}

To-do List

  • require replaced URLs to be in src or href attributes

  • allow external config file which does not get committed to repo

    • allows different local URLs on different development machines

  • implement as a railtie and load middleware automatically on app_middleware config hook

Copyright © 2009-10 Alex Reisner, released under the MIT license

About

Rails plugin for loading CDN content locally when not connected to the Internet.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages