Add entire folder of JavaScript files to HTML5 App Cache - javascript

I have a huge set of JavaScript files that need to be added to the App cache. Is it possible to add an entire folder(JS folder) in the Manifest. Else, I'll have to manually add those JS files to the manifest.

Your manifest file doesn't need to be a static file. Just write some server side code to generate a manifest based on the files in the folder.

As Maurice has pointed out, you can generate the file dynamically.
Or better still, have a background task do the work when the contents of the folder changes.
Node.js is good for this if you are already familiar with JS and have control over the server so that it can be installed. Node comes with capabilities for watching files and folders & there are a number of libraries available to make the job simple.
One key issue to watch out for though is the combined size of the files. Many browsers that support HTML5 offline use, put strict limits on the amount of data you can store offline. Typically the default limit is 5MB.

Related

Clean wordpress .css cached from origin files

My website is developed in Wordpress and currently in production.
I've noticed .css file is cached in public_html/wp-content/cache/min/1/b1245204d8e0a4ff7cb5d1b2577fb6fa.css and every time any client request the website the same .css and others .js files generates several with random names.
Currently I'm on charge optimize WEB Core Vitals and one of the key is Performance, but I have no idea which origin files do I need to edit or modify in order when the cache re-generate those new files apply the origin changes.
It's been challenging to identify which file but not the original one.
I also use Google Dev Tool > Coverage to detect which file is affecting the performance, but it's not a good thing to modify the cached file.
Appreciate any idea or help.

How to purge browse cache - index.html stuck in cache

I have a ReactJS app hosted in S3 and using Cloudflare as DNS & CDN.
I have a huge issue, a lot of visitors have old version of the application stored in their browser cache (index.html only). I have configured advanced cache control in the newest version, but it cannot be accessed because older version is shown instead.
Static file (CSS, JS) versioning is done using create-react-app, but I have discovered that index.html file is the only cached one.
What should I do now?
How to purge visitors cache now?
PS: I have purged Cloudflare cache already and setup rule to bypass cache.
Unfortunately there is no such solution for this.
The only way is to wait until users cache will empty (expire).
It is technicaly impossible to clear users cache from external resource (JS script etc.), due to security reasons.
Also if it will be possible, there is no way how to tell users to download latest JS (including cache purging code), because they have old version of index.html (including link to those .js files).
You are stack and the only option is to wait.
A better approach would be, whenever your build changes, change the JS link so that the browser downloads the new version from the server, no matter the user's or the server's caching policy.
For example, the way Stack Exchange does it is, whenever the build changes, the HTML goes from something like:
<script src="https://cdn.sstatic.net/Js/stub.en.js?v=1bac371ac78f"></script>
to
<script src="https://cdn.sstatic.net/Js/stub.en.js?v=f83b2f654"></script>
Whenever there's a new build, you can randomize the parameter in the query string in the HTML, and still only have the single (most recent) built .js on your server.

How to serve updatable Javascript files from a cdn

So here is the problematic.
I work for a company that generate customizable javascript files for each clients. Each client has to include the script on their product pages. The client can modify the configuration of the script at anytime.
What we are doing now is that we are managing all that internally but i was wondering if it was possible to serve those file from a cdn knowing that we must be able to modifify the files on the cdn when a client modify his configuration, and that the changes must take effect immediately.
do you have control over the save action? if so you could version the file on save and keep track of the latest version. then you can use it in your page builder and load the page: file.js?v= instead of just loading file.js directly.

Failed to load large JavaScript file ExpressJS after uglifying

All my scripts are compressed and minified used uglifyJS:
The size of this file "app.min.js" is 982.1KB however when I tried to run the node server and open the app in the browser It's stopped in 502kB
and after some while
I don't know what happened there, Is there any limitation on Javascript file '502kB' ?
what I miss
I think this article may help you, it is all about nodejs server serving static content, so nginx is recommended to do this purpose.
If you have to use nodejs server then you should make all files smaller in terms of size, no need for example to minimize libraries files as jquery since it is already minimized, scripts should be minimized only, you can even minimize all libs files into one javascript file called libs.min.js as example and the rest of your scripts in another file called script.min.js.

Does Javascript support the ability to get a directory listing?

I want to upload a bunch of image files to a directory that I've set up on my ISP's free hosting service. It's something like http://home.ISPname.net/~username/subdir.
I want my Javascript code to be able to get a directory listing and then preload whatever it finds.
But getting such a thing even possible? My impression is not.
I suspect I will have to instead rename my files to 00000.jpg and upward, and attempt to detect what files are there using try.
FYI, I know that my ISP does not support using FTP protocol to get a directory listing.
Thanks for any help.
Under the assumption that your JavaScript code is code on your pages and not code on your server, then no, there's no API provided for JavaScript in a web browser other than a server-side API accessible via HTTP that you would create yourself. If the directory full of files is on the server, then it's going to have to be some server-side code that delivers the directory listing anyway. You could write such code in the server-side programming environment of your choice (including a server-side JavaScript solution, if that's what you want and if such a thing is possible at your ISP). As Pekka notes, it may be possible to simply enable directory browsing in your server, though that's generally a fairly low-level service that will deliver some sort of HTML page to you, and parsing through that might be somewhat painful (compared to what you could get from a tailor-made service).
Another, simpler thing you could do would be to upload a manifest file along with the other image files. In other words, create the directory listing in some easy-to-digest form, and maintain it separately as a simple file to be fetched.
javascript not suport directory listing in a direct way. but you can create a directory dumper php file, and send via AJAX.

Categories

Resources