I am experiencing the same issues that I’ve seen others post about in the forum where my old asset files are not saved, Chunk Load Errors occur, and my website “breaks” when I push a change. I deploy updates many teams a day/week, so this behavior doesn’t lead to the best end-user experience (especially if they don’t know to refresh the page).
I don’t know if this is possible, but I am exploring the Deploy Notification webhooks and want to see if the Build ID (or some other value unique to the deploy) variable is available to the webhook. I’m envisioning sending the completed webhook to my own site, handling it with a lamda-function, and storing the variable in the database. That way, I can programatically check if the user is on the most recent version of the website, and if they are not, provide a prompt for them to refresh the page. I see this replacing the not so pretty way of catching Chunk Load Errors (for JS and CSS) which is not so easy to test and not the best solution for me.
Is this possible? I believe it makes way more sense than any other approach. I absolutely love Netlify, but having constant errors due to deploying non-breaking updates/changes doesn’t seem right.
Edit: Maybe this flow would work?
- Successful build hook to sent lambda function on site
- Lambda function does a
GET /api/v1/hooks?site_id=:site_idwith the site_id and Oauth credentials saved as netlify variables
- Get the SiteID from the response, save it to the DB
- Save the site ID to a local variable on user’s browser. Compare local variable with what is saved in DB- if differs, notify user a newer version of the site has been released and prompt the user to refresh.
Any input from an experienced dev is greatly appreciated.