vidibus-asset_cache_buster 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.rdoc +39 -0
- data/Rakefile +20 -0
- data/lib/vidibus-asset_cache_buster.rb +5 -0
- data/lib/vidibus/asset_cache_buster.rb +40 -0
- data/lib/vidibus/asset_cache_buster/version.rb +5 -0
- data/vidibus-asset_cache_buster.gemspec +26 -0
- metadata +152 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 Andre Pankratz
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
= Vidibus::AssetCacheBuster
|
|
2
|
+
|
|
3
|
+
Rewrites cache buster for assets to a static string that is sure to be cached by proxy servers.
|
|
4
|
+
|
|
5
|
+
Example:
|
|
6
|
+
|
|
7
|
+
/stylesheets/screen.css?1297772836
|
|
8
|
+
|
|
9
|
+
will become
|
|
10
|
+
|
|
11
|
+
/stylesheets/screen.1297772836.css
|
|
12
|
+
|
|
13
|
+
For more information about proxy caching, take a look at the documentation of Google's {Page Speed}[http://code.google.com/intl/de-DE/speed/page-speed/docs/caching.html#LeverageProxyCaching] tool.
|
|
14
|
+
|
|
15
|
+
This gem is part of the open source service-oriented {video framework}[http://vidibus.org] Vidibus.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
== Installation
|
|
19
|
+
|
|
20
|
+
Add the dependency to the Gemfile of your application:
|
|
21
|
+
|
|
22
|
+
gem "vidibus-asset_cache_buster"
|
|
23
|
+
|
|
24
|
+
Then call bundle install on your console.
|
|
25
|
+
|
|
26
|
+
To get this solution working, it is required to add some configuration to your Apache2 VirtualHost:
|
|
27
|
+
|
|
28
|
+
# Remove timesstamp from versioned static javascripts, stylesheets, and images.
|
|
29
|
+
# This requires a change in Rails so that assets will be included as image.12345.jpg
|
|
30
|
+
RewriteEngine on
|
|
31
|
+
RewriteRule ^/(javascripts|stylesheets|images)/(.+)\.(.+)\.(js|css|jp?g|gif|png)$ /$1/$2.$4 [L]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
This rewrite does not support SSL yet. Maybe Apache2 config should be improved...
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
== Copyright
|
|
38
|
+
|
|
39
|
+
Copyright (c) 2011 Andre Pankratz. See LICENSE for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "bundler"
|
|
2
|
+
require "rake/rdoctask"
|
|
3
|
+
require "rspec"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
Bundler::GemHelper.install_tasks
|
|
6
|
+
|
|
7
|
+
Rspec::Core::RakeTask.new(:rcov) do |t|
|
|
8
|
+
t.pattern = "spec/**/*_spec.rb"
|
|
9
|
+
t.rcov = true
|
|
10
|
+
t.rcov_opts = ["--exclude", "^spec,/gems/"]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Rake::RDocTask.new do |rdoc|
|
|
14
|
+
require File.expand_path("../lib/vidibus/asset_cache_buster/version.rb", __FILE__)
|
|
15
|
+
rdoc.rdoc_dir = "rdoc"
|
|
16
|
+
rdoc.title = "vidibus-sysinfo #{Vidibus::AssetCacheBuster::VERSION}"
|
|
17
|
+
rdoc.rdoc_files.include("README*")
|
|
18
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
|
19
|
+
rdoc.options << "--charset=utf-8"
|
|
20
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Vidibus
|
|
2
|
+
|
|
3
|
+
# Rewrite cache buster for assets.
|
|
4
|
+
# To get this solution working, it is required to add some configuration to your apache2 VirtualHost:
|
|
5
|
+
#
|
|
6
|
+
# # Remove timesstamp from versioned static javascripts, stylesheets, and images.
|
|
7
|
+
# # This requires a change in Rails so that assets will be included as image.12345.jpg
|
|
8
|
+
# RewriteEngine on
|
|
9
|
+
# RewriteRule ^/(javascripts|stylesheets|images)/(.+)\.(.+)\.(js|css|jp?g|gif|png)$ /$1/$2.$4 [L]
|
|
10
|
+
#
|
|
11
|
+
# This rewrite does not support SSL. Maybe Apache2 config should be improved...
|
|
12
|
+
#
|
|
13
|
+
module AssetCacheBuster
|
|
14
|
+
|
|
15
|
+
# Only works with integer timestamps!
|
|
16
|
+
def asset_file_path(path)
|
|
17
|
+
return super if request.ssl?
|
|
18
|
+
if path.match(/^(.+?)(\.\d+)?(\..+)$/)
|
|
19
|
+
path = "#{$1}#{$3}"
|
|
20
|
+
end
|
|
21
|
+
File.join(config.assets_dir, path)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def rewrite_asset_path(source, path = nil)
|
|
25
|
+
return super if request.ssl?
|
|
26
|
+
if path && path.respond_to?(:call)
|
|
27
|
+
return path.call(source)
|
|
28
|
+
elsif path && path.is_a?(String)
|
|
29
|
+
return path % [source]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
asset_id = rails_asset_id(source)
|
|
33
|
+
if asset_id.blank?
|
|
34
|
+
source
|
|
35
|
+
else
|
|
36
|
+
source.gsub(/^(.+)(\..+)$/,"\\1.#{asset_id}\\2")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path("../lib/vidibus/asset_cache_buster/version", __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "vidibus-asset_cache_buster"
|
|
6
|
+
s.version = Vidibus::AssetCacheBuster::VERSION
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.authors = "Andre Pankratz"
|
|
9
|
+
s.email = "andre@vidibus.com"
|
|
10
|
+
s.homepage = "https://github.com/vidibus/vidibus-asset_cache_buster"
|
|
11
|
+
s.summary = "Leverages proxy caching for static assets."
|
|
12
|
+
s.description = "Rewrites cache buster for assets to a static string that is sure to be cached by proxy servers."
|
|
13
|
+
|
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
|
15
|
+
s.rubyforge_project = "vidibus-asset_cache_buster"
|
|
16
|
+
|
|
17
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
|
18
|
+
s.add_development_dependency "rake"
|
|
19
|
+
s.add_development_dependency "rspec", "~> 2.0.0.beta.20"
|
|
20
|
+
s.add_development_dependency "rr"
|
|
21
|
+
s.add_development_dependency "relevance-rcov"
|
|
22
|
+
|
|
23
|
+
s.files = `git ls-files`.split("\n")
|
|
24
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
|
25
|
+
s.require_path = 'lib'
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vidibus-asset_cache_buster
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 29
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 0
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.0.1
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Andre Pankratz
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2011-02-15 00:00:00 +01:00
|
|
19
|
+
default_executable:
|
|
20
|
+
dependencies:
|
|
21
|
+
- !ruby/object:Gem::Dependency
|
|
22
|
+
name: bundler
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 23
|
|
30
|
+
segments:
|
|
31
|
+
- 1
|
|
32
|
+
- 0
|
|
33
|
+
- 0
|
|
34
|
+
version: 1.0.0
|
|
35
|
+
type: :development
|
|
36
|
+
version_requirements: *id001
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: rake
|
|
39
|
+
prerelease: false
|
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
hash: 3
|
|
46
|
+
segments:
|
|
47
|
+
- 0
|
|
48
|
+
version: "0"
|
|
49
|
+
type: :development
|
|
50
|
+
version_requirements: *id002
|
|
51
|
+
- !ruby/object:Gem::Dependency
|
|
52
|
+
name: rspec
|
|
53
|
+
prerelease: false
|
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
55
|
+
none: false
|
|
56
|
+
requirements:
|
|
57
|
+
- - ~>
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
hash: 62196427
|
|
60
|
+
segments:
|
|
61
|
+
- 2
|
|
62
|
+
- 0
|
|
63
|
+
- 0
|
|
64
|
+
- beta
|
|
65
|
+
- 20
|
|
66
|
+
version: 2.0.0.beta.20
|
|
67
|
+
type: :development
|
|
68
|
+
version_requirements: *id003
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rr
|
|
71
|
+
prerelease: false
|
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ">="
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
hash: 3
|
|
78
|
+
segments:
|
|
79
|
+
- 0
|
|
80
|
+
version: "0"
|
|
81
|
+
type: :development
|
|
82
|
+
version_requirements: *id004
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: relevance-rcov
|
|
85
|
+
prerelease: false
|
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
87
|
+
none: false
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
hash: 3
|
|
92
|
+
segments:
|
|
93
|
+
- 0
|
|
94
|
+
version: "0"
|
|
95
|
+
type: :development
|
|
96
|
+
version_requirements: *id005
|
|
97
|
+
description: Rewrites cache buster for assets to a static string that is sure to be cached by proxy servers.
|
|
98
|
+
email: andre@vidibus.com
|
|
99
|
+
executables: []
|
|
100
|
+
|
|
101
|
+
extensions: []
|
|
102
|
+
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
|
|
105
|
+
files:
|
|
106
|
+
- .gitignore
|
|
107
|
+
- Gemfile
|
|
108
|
+
- LICENSE
|
|
109
|
+
- README.rdoc
|
|
110
|
+
- Rakefile
|
|
111
|
+
- lib/vidibus-asset_cache_buster.rb
|
|
112
|
+
- lib/vidibus/asset_cache_buster.rb
|
|
113
|
+
- lib/vidibus/asset_cache_buster/version.rb
|
|
114
|
+
- vidibus-asset_cache_buster.gemspec
|
|
115
|
+
has_rdoc: true
|
|
116
|
+
homepage: https://github.com/vidibus/vidibus-asset_cache_buster
|
|
117
|
+
licenses: []
|
|
118
|
+
|
|
119
|
+
post_install_message:
|
|
120
|
+
rdoc_options: []
|
|
121
|
+
|
|
122
|
+
require_paths:
|
|
123
|
+
- lib
|
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
|
+
none: false
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
hash: 3
|
|
130
|
+
segments:
|
|
131
|
+
- 0
|
|
132
|
+
version: "0"
|
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
|
+
none: false
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
hash: 23
|
|
139
|
+
segments:
|
|
140
|
+
- 1
|
|
141
|
+
- 3
|
|
142
|
+
- 6
|
|
143
|
+
version: 1.3.6
|
|
144
|
+
requirements: []
|
|
145
|
+
|
|
146
|
+
rubyforge_project: vidibus-asset_cache_buster
|
|
147
|
+
rubygems_version: 1.3.7
|
|
148
|
+
signing_key:
|
|
149
|
+
specification_version: 3
|
|
150
|
+
summary: Leverages proxy caching for static assets.
|
|
151
|
+
test_files: []
|
|
152
|
+
|