Skip to content

Instantly share code, notes, and snippets.

@tilsammans
Created August 7, 2017 16:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tilsammans/5512def5c88aafc7fb9fbd5309129d02 to your computer and use it in GitHub Desktop.
Save tilsammans/5512def5c88aafc7fb9fbd5309129d02 to your computer and use it in GitHub Desktop.
Middleman Netlify HTTP/2 Server Push
ready do
# Insert fingerprinted asset paths into _headers for Netlify.
proxy "/_headers", "/headers.txt",
layout: false,
locals: {
# these variables will be different for you. Add at will!
all_css: sitemap.find_resource_by_path('css/all.css'),
vendor_js: sitemap.find_resource_by_path('js/vendor.js'),
main_js: sitemap.find_resource_by_path('js/main.js')
},
ignore: true
end
# This file goes in your Middleman `source` directory.
# configure HTTP/2 Server Push
/
Link: <<%= all_css.url %>>; rel=preload; as=style
Link: <<%= vendor_js.url %>>; rel=preload; as=script
Link: <<%= main_js.url %>>; rel=preload; as=script
# Set a long cache expiry on asset urls
<%= all_css.url %>
Cache-Control: public, max-age=31556926
<%= vendor_js.url %>
Cache-Control: public, max-age=31556926
<%= main_js.url %>
Cache-Control: public, max-age=31556926
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment