tl;dr:
I'm wondering if there's a benefit to prefetching certain images bundled with my browser extension, or if they will always be served from cache—even on first request?
Context
In my extension, I have a few images listed at the web_accessible_resources key of my manifest.json file. Occasionally, one of these images seems to take a long time to load (or to have failed entirely).
I was going to implement a kind of prefetching for the problem image, but when I inspect the image requests in the Network tab of Chrome Dev Tools, I see that these images always come (from disk cache) or (from memory cache)—even after I uninstall/reinstall the extension and clear browser cache.
This makes me believe that the offending image will not be affected by prefetching, as it is already coming from the cache. I'd like to rule prefetching out as a solution before considering more exotic options.
Related
I was trying to download spark-hadoop distribution from the website - https://archive.apache.org/dist/spark/spark-3.1.2/. Often I find that the downloads from this site are generally slow. Is it due to some generic issue with the site itself?
That the download is slow I have verified in two ways -
In Colab I have run the command !wget -q https://archive.apache.org/dist/spark/spark-3.1.2/spark-3.1.2-bin-hadoop3.2.tgz which keeps running often for more than say 10 minutes. While at other times it executes within 1 minute.
From the website I tried downloading it and even then the download speed is extremely slow occasionally.
It maybe because
You download multiple times
You download from non-browser, for example curl/wget
Your location is physically far from file server or network is unstable.
or something else. for example file server is slow
I think most of public server has kind a "safe guard" to prevent DDoS, So their "Safe guard" control download traffic per sec.
I faced similar issue, when I download from browser, it took 1min, but It took 10min when I use curl
I've investigated this and found lots of related information, but nothing that answers my question.
A little background. A small set of files are shared by IIS 10 statically. These files need to be updated usually weekly, but not more than once an hour (unless someone manually runs an update utility for testing). The files are expected to be a couple K bytes in size, no larger then 10 kilobytes. The update process can be run on the IIS server and will be written in PowerShell or C#.
My plan for updating files that are actively being served as static files by IIS is:
Copy the files to a temporary local location (on the same volume)
Attempt to move the files to the IIS static site location
The move may fail if the file is in use (by IIS). Implement a simple retry strategy for this.
It doesn't cause a problem if there is a delay in publishing these files. What I really want to avoid is IIS trying to access one of the files at just the wrong time, a race condition while my file replacement is in process. I have no control over the HTTP client which might be a program that's not tolerant of the type of error IIS could be expected to return, like an HTTP status 404, "Not Found".
I have a couple random ideas:
HTTP GET the file from IIS before I replace it with the intention of getting the file into IIS's cache in hopes that will improve the situation.
Just ignore this potential issue an hope for the best
I can't be the only developer who's faced this. What's a good way to address this issue? (Or is it somehow not an issue at all and I'm just over thinking it?)
Thanks in advance for any help.
I'm a little surprised that I can't find this answered already, but I've looked fairly hard. Apologies if I've missed it somewhere obvious.
TL;DR
Question: How do I configure CRA (with SW) and the Azure App Service into which it is deployed, so that they play nicely together?
There is a relatively well-discussed caching gotcha in the (current) default CreateReactApp config, relating to serviceWorkers.
It is lightly-discussed here, in the CRA docs: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#user-content-opting-out-of-caching (especially, points 5 & 6 from "Offline-First Considerations").
And an extended argument about its original inclusion in CRA can be found here: https://github.com/facebook/create-react-app/issues/2398
I'm not 100% certain of my understanding, so I'm going to start by summarising what I currently believe to be true:
CRA has setup standard cache-busting processes in its main files.
CRA has included a "Service Worker" pattern to do heavy-duty, ultra-sticky caching.
The Service Worker can mostly load the page without even having an internet connection.
In principle the SW will load the page, and then go and ask the server about the latest code.
If it detects a newer version, it will download that, and cache the new version.
It will NOT immediately display the new version, but would use the new version the next time the page is loaded, from its newly-updated cache.
All this is the standard, desired, intended behaviour of Service Workers.
But further to this:
The serviceWorker is NOT cache busted.
Depending on your host server configuration, the serviceWorker itself may get cached.
If that happens, then it will permanently display the stale version of the site, until the serviceWorker is cleared from the cache, and then it will start trying to update the available content.
Default, out-of-the-box Azure configuration does cache the SW, and so far (after 24 hours) doesn't seem to release that cache at all :(
Question 0: Have I got everything above correct, or am I missing something?
I like the sound of the serviceWorker in general - it seems like it's doing a useful job, but it seems very unlikely that the CRA has provided something which when installed Out-of-box into Azure is fundamentally broken - the site I've deployed at the moment is (or gives the impression of being) impossible to push updates to!
I believe I know how to turn off the ServiceWorker, apparently including active steps required to purge it from people's browsers who have already seen it once and thus have an active SW already. (Though I don't understand clearly how that code will work!?) But I'd rather not do that if I can avoid it - I'd rather understand how to work WITH this feature, than how to DISABLE this feature.
So ...
Question: How do I configure CRA (with SW) and the Azure App Service into which it is deployed, so that they play nicely together?
When we hit any URL( like Facebook.com) on any browser(like chrome) it uses many resources for that particular page like JS files, Images, properties files etc. So, are they stored locally temporarily ?
Yes, it's called the browser cache :-) Websites can also use local storage to store some data on your machine. Additionally along the way various servers might cache the resources. ISPs do this a lot.
According to this link:
"If you serve your images from multiple hostnames, you can get more than two downloads to occur in parallel. (I've gotten Internet Explorer to download over 100 images in parallel.) While a script is downloading, however, the browser won’t start any other downloads, even on different hostnames."
What I wonder is why downloading script prevents parallelism? I guess browser executes the script right after the download finishes. So why not to download them in parallel, but defer only execution? Is it an implementation choice? Is there any other reason for that?
The browser executes the script as it is downloading it, so it will not get any further on the page to see what else there is that it needs to download. You can use something like LABjs to help with this though: http://labjs.com/