Clear the browser cache
-
- Profound User
- Posts: 39
- Joined: Mon Aug 21, 2017 11:48 am
- First Name: Jose
- Last Name: hernandez Guerra
- Company Name: CM de gestion y servicios S.L.
- Phone: 638489712
- Address 1: CL Jose Luis de Cassos 50
- City: Sevilla
- State / Province: Outside Canada/USA
- Zip / Postal Code: 41005
- Country: Spain
- Contact:
Clear the browser cache
Hello everyone, is there any api in Profoundui that clean the browser cache ??
The case is the following, I upload an image through the widget, that image has a fixed name (EAN code of the article), once the upload is done, I show the image that has been uploaded, but if I want to upload the same reference again name but with another image (for whatever reason) shows me the previous image. That is what is in cache. can be avoided by clearing the browser cache before uploading the image again. But there is not an Api that can do that without the user having to use the History and browser cache cleaners ??
Thank you
The case is the following, I upload an image through the widget, that image has a fixed name (EAN code of the article), once the upload is done, I show the image that has been uploaded, but if I want to upload the same reference again name but with another image (for whatever reason) shows me the previous image. That is what is in cache. can be avoided by clearing the browser cache before uploading the image again. But there is not an Api that can do that without the user having to use the History and browser cache cleaners ??
Thank you
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Clear the browser cache
It's not possible for an application running in a web browser to clear the browser's cache -- and, even if it were, this would not be a good idea. Clearing the cache would affect every single page that a user visits, not just your program. Even if your user only uses it for Profound UI, it would be an absolute disaster for performance. It is a bad approach.
If the goal is simply to refresh one image, simply change the image URL each time. This technique is often called a "cache buster", and is very common, used by web programmers of all sorts, throughout the world. The same technique works with Profound UI as would work with HTML -- the only difference is that you change a widget property instead of an HTML tag.
For example, if your "image source" property currently looks like this:
You would change it to look like this:
This keeps the filename the same "image123.jpg" but adds a random number to the end of the URL. Since that random number is different every time, the image is never loaded from the browser's cache.
If the goal is simply to refresh one image, simply change the image URL each time. This technique is often called a "cache buster", and is very common, used by web programmers of all sorts, throughout the world. The same technique works with Profound UI as would work with HTML -- the only difference is that you change a widget property instead of an HTML tag.
For example, if your "image source" property currently looks like this:
Code: Select all
/myimages/image123.jpg
Code: Select all
script: "/myimages/image123.jpg?r=" + Math.floor(Math.random() * 1000000000);
-
- Profound User
- Posts: 39
- Joined: Mon Aug 21, 2017 11:48 am
- First Name: Jose
- Last Name: hernandez Guerra
- Company Name: CM de gestion y servicios S.L.
- Phone: 638489712
- Address 1: CL Jose Luis de Cassos 50
- City: Sevilla
- State / Province: Outside Canada/USA
- Zip / Postal Code: 41005
- Country: Spain
- Contact:
Re: Clear the browser cache
Thank you very much Scott
-
- Profound User
- Posts: 39
- Joined: Mon Aug 21, 2017 11:48 am
- First Name: Jose
- Last Name: hernandez Guerra
- Company Name: CM de gestion y servicios S.L.
- Phone: 638489712
- Address 1: CL Jose Luis de Cassos 50
- City: Sevilla
- State / Province: Outside Canada/USA
- Zip / Postal Code: 41005
- Country: Spain
- Contact:
Re: Clear the browser cache
Okay. it works very well, but does not make the image always download?
It would not affect the performance ??
Thank you
It would not affect the performance ??
Thank you
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Clear the browser cache
It does make this image always download. (But does not affect everything else.)
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Clear the browser cache
Scott,
Would this also work for loading external javascript?
Right now, I'm loading some external javascript in the window's onload event like this:
could I do something like
Would this also work for loading external javascript?
Right now, I'm loading some external javascript in the window's onload event like this:
Code: Select all
pui.loadJS(pui.normalizeURL("/profoundui/userdata/js/transfers.js"));
pui.loadCSS(pui.normalizeURL("/profoundui/userdata/css/NexusDevice.css"));
Code: Select all
var jsFile = "/profoundui/userdata/js/transfers.js?r=" + Math.floor(Math.random() * 10000000);
pui.loadJS(pui.normalizeURL(jsFile));
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Clear the browser cache
Mark, I think that'd work, but I'm not sure. There's a good chance that it'd cause other problems (like memory leaks) but I'm not sure about that, either...
Can you explain why you want to do that? Would using JavaScript's eval() capability be a better solution?
Can you explain why you want to do that? Would using JavaScript's eval() capability be a better solution?
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Clear the browser cache
We currently have a fleet of Zebra tablets deployed using MobiControl to lock them down. We've been making changes to some external javascript files and have had issues where the tablets aren't getting the most recent code.
Clearing the cache is not an option for the users. They need to be taken out of MobiControl, then cleared by IT, then put back into MobiControl.
Can you be more clear as to what the eval() function will do for me?
Clearing the cache is not an option for the users. They need to be taken out of MobiControl, then cleared by IT, then put back into MobiControl.
Can you be more clear as to what the eval() function will do for me?
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Clear the browser cache
eval() is used to evaluate JavaScript code at runtime. For example, if you had JS code in a string variable and wanted to run it. It doesn't sound like that's applicable to your situation, though.
I misread the event you were using, I thought you were wanting to replace the JS code as a particular screen was loading. I see now that you want to do it when the browser's window object is loading... that makes more sense. That sounds like it'd work fine.
I misread the event you were using, I thought you were wanting to replace the JS code as a particular screen was loading. I see now that you want to do it when the browser's window object is loading... that makes more sense. That sounds like it'd work fine.
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Clear the browser cache
Thanks for the conformation.
Who is online
Users browsing this forum: No registered users and 6 guests