Add headers file for netlify http2/push and caching Prevent empty js from loading
Tom Rutgers
committed Aug 17, 2018
commit 28d7a525377c3b81bb30345585c03bc0a08df45a
Showing 2
changed files with
17 additions
and 1 deletions
source/_headers.txt.erb
+16
-0
| @@ | @@ -0,0 +1,16 @@ |
| + | # Configure HTTP/2 Server Push |
| + | |
| + | <% sitemap.resources.select { |resource| resource.path =~ /\.(html)/ }.each do |resource| %> |
| + | <%= resource.url %> |
| + | Link: <<%= sitemap.find_resource_by_path('stylesheets/all.css').url %>>; rel=preload; as=style |
| + | <%end%> |
| + | |
| + | # Set a long cache expiry on assets with font or image extensions |
| + | <% sitemap.resources.select { |resource| resource.path =~ /\.(css|js|svg|jpg|png)/ }.each do |resource| %> |
| + | <%= resource.url %> |
| + | <%if resource.path =~ /\.(json|xml)/%> |
| + | Cache-Control: public, max-age=0 |
| + | <%else%> |
| + | Cache-Control: public, max-age=31556926 |
| + | <%end%> |
| + | <%end%> |
source/layouts/layout.slim
+1
-1
| @@ | @@ -10,7 +10,7 @@ html |
| title= current_page.data.title || "Middleman" | |
| = stylesheet_link_tag "all" | |
| - | = javascript_include_tag "main" |
| + | |
| // Include netlify identity widget for user registration | |
| script src="https://identity.netlify.com/v1/netlify-identity-widget.js" type="text/javascript" | |
| body | |