Caching issues again after uploading to app catalog
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
SPFx 1.22.1
What browser(s) / client(s) have you tested
- [x] 💥 Microsoft Edge
Describe the bug / error
We're seeing similar caching issues again that were happening a year or two ago and fixed. After uploading to the tenant or site app catalog the new version is showing in the catalog but not being shown on sites that use it for 30+ minutes or sometimes it will show the new version and revert to the old as you click through various pages on the site. This is happening for apps that are 100 KB or 50 MB.
This makes it very difficult to release the code especially if we have APIs that are also released at the same time that do not work with the old version. Web parts are essentially broken until the new version appears on the site. This also makes it hard for our QA team to do smoke tests after releases and creates a lot of downtime that are clients are not expecting.
Let me know if there's any information I can pass along to help debug this.
Previous times this happened https://github.com/SharePoint/sp-dev-docs/issues/8915 https://github.com/SharePoint/sp-dev-docs/issues/8803
Steps to reproduce
- Package solution and upload to tenant or site app catalog.
- Verify new version is uploaded
- Refresh site that contains web parts from solution.
- Old web parts are still showing
Expected behavior
New version should appear on sites immediately or within a few minutes.
Hello @kbeverforden,
Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.
If you don’t receive a reply within two working days, please use this escalation form to escalate.
@kbeverforden, We have successfully reproduced this caching issue with SPFx 1.22.1 on SharePoint Online. After deploying version 2.0.0 to the App Catalog, pages intermittently continue serving version 1.0.0, confirming the behavior described in this thread. We are raising this with our engineering team to determine whether a fix is feasible or if this remains expected platform behavior. We will update this thread once we receive guidance from the product team.
Thanks!
I can confirm we experience the same problem with SPFx 1.22.1. We must sometimes wait up to 1 hour until the new version is available. In our case we deploy our solution to the site app catalog.
I think the problem is due to the fact that solution JavaScript files do not have an associated hash anymore, and the CDN will be slower to update them. With Version 1.21 and before, the files were:
- In the solution package:
ClientSideAssets/my-code_3d08fac1babea05bf467.js - In the SharePoint site:
ClientSideAssets/<guid>/my-code_3d08fac1babea05bf467.js - Served by the CDN:
https://public-cdn.sharepointonline.com/org.sharepoint.com/sites/my-site/ClientSideAssets/<solution guid>/my-code_3d08fac1babea05bf467.js=> with a new version of my solution, the URL will be different
Now, with version 1.22.1, the files are :
- In the solution package:
ClientSideAssets/my-code.js - In the SharePoint site:
ClientSideAssets/<guid>/my-code.js - Served by the CDN:
https://public-cdn.sharepointonline.com/org.sharepoint.com/sites/my-site/ClientSideAssets/<solution guid>/my-code.js=> with a new version of my solution, the URL remains the same
When inspecting the headers of the CDN JavaScript file request, I can see the following header:
I could observe that when I had an older version of the SPFx web part on the page:
- A simple reload of the page would not help
- However a force reload (Ctrl+F5) updated the version
- Another time, reloading the page with the Chrome dev tools open on the Network tab, with the "Disable cache" option also helped loading the newer version
So the problem is likely a combination of the CDN file propagation delay and the browser caching an older version of the package files even if a newer one is already available in the CDN.
After further checking, SPFx 1.22.1 and 1.22.2 correctly support adding hashes to package file names, as long as the --production parameter is used in the heft build command.
Our problem was that the build in Azure DevOps was done with the following task:
- task: Npm@1
displayName: heft build --production
inputs:
command: custom
customCommand: exec heft build --production
workingDir: ${{ parameters.solutionDir }}
This results in the following command being executed in the pipeline:
npm exec heft build --production
The problem here is that the --production parameter is consumed by npm, not by heft. As a result, heft does a development build and package files do not contain a hash.
If we add a -- token (see npx vs npm exec) between exec and heft, the --production parameter is consumed by heft and hashes are generated as intended:
- task: Npm@1
displayName: heft build --production
inputs:
command: custom
customCommand: exec -- heft build --production
workingDir: ${{ parameters.solutionDir }}
Resulting command in the pipeline:
npm exec -- heft build --production
By deploying packages including file name hashes, the change propagation issue I described above is solved.