I’ve just spent a day or so implementing skew protection for our site (that doesn’t use vercel or astro). And thought I’d send a quick bit of feedback about the documentation/feature.
-
It might be helpful to document that the
.netlify/v1/folder is kind of weird. As far as I can tell you cannot check it in to the repo, as it will be ignored/overwritten by netlify during the build.You also can’t just copy it from say
cp _netlify .netlifyduring the build as the netlify build creates and uses.netlifyduring it’s own setup.So you must explicitly write the files to
.netlify/v1one at a time (and create the directory if it doesn’t exist). -
There’s some interesting handling with redirects and skew protection. I think it actually does make sense but it confused me for a while.
If you have a redirect for say
/* => index.html (200)if you try and load (in your browser) something likemyscript.SHA.js?deploy_id=past_deploynetlify will return the current index.html instead of the file from the previous build. But if youfetchorcurlthe same url netlify will return the previous build’s JS file correctly.I think this makes some sense, to stop people getting stuck on the old deploy if you are using cookies, but it confused me for a bit.
-
It would be have been super helpful if anywhere in the UI/logs the build indicated that it had enabled skew protection and with what settings.
-
There are some caveats that might be worth highlighting, unless there is a way to solve for them I’m unaware of?
- Cookie based would the best from a caching/simplicity perspective; and we started with that; but realised that since cookies are shared between tabs, it just creates a new skew problem. As if someone has an old version tab open; and then opens the new version, the cookie will get updated; and now the old version tab will be broken again, as it’ll request old version URLS with a new version deploy id
- Query param is then where you end up, and the only other choice for e.g script/css tags; but the downside is that I believe adding the query param will bust caches. So if a file isn’t changed between deploys it’s cache will now be bust on every deploy.