How to specify Headers for only html responses

answered
#1

Hi Netlify folks,

So as mentioned here you can use wildcards to specify various routes:

I wanted to ask if there is a way to target only html responses? Is there any way to specify exclude “*.js”?

#2

There is no way to match “everything except X” in our system at present. You can of course target only html responses if your URL’s actually end with html:

/*html
  Header: value

If you could let me know what is it you’re trying to accomplish in some more detail, we might be able to come up with a way to do it that isn’t using that facility.

#3

So I was thinking of trying out http2 push.
I have a vendor bundle loaded on every page so I thought I should use

/*
  Link </static/vendor.js> ; rel=preload; as=script

I still haven’t tested it out whether this header will get added to js, css, image and other assets as well. I would not want to serve this header to js and css assets.

#4

Since HTTP/2 push is disabled right now and we don’t have a timeline for re-enabling, I guess that experiment probably won’t do much good for you.

Once re-enabled, we do have facilities in place to ONLY push for html files already in that case since everyone misconfigured it and was double-loading their CSS and JS files :wink: