Add prefix option to asset_hash (#1949)
This allows manually changing the filename so that fiel header changes can be reflected on the CDN. E.g. if you turn on crossOrigin serving (CORS) the asset hash doesn't change, but the CDN cache needs to be broken in order to pickup the new header.
This commit is contained in:
parent
ea39d16d81
commit
389e3f5a8c
8 changed files with 65 additions and 1 deletions
16
middleman-core/fixtures/asset-hash-prefix/lib/middleware.rb
Normal file
16
middleman-core/fixtures/asset-hash-prefix/lib/middleware.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class Middleware
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
status, headers, response = @app.call(env)
|
||||
body = ''
|
||||
response.each {|part| body += part }
|
||||
if (env["PATH_INFO"] =~ /css$/)
|
||||
body += "\n/* Added by Rack filter */"
|
||||
status, headers, response = Rack::Response.new(body, status, headers).finish
|
||||
end
|
||||
[status, headers, response]
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue