Introduction
Ignitions Perspective module features some components that serve as wrappers for instances of a Chromium browser and with that comes powerful features like being able to make HTTP GET requests to any domain on the internet. Since this is all happening inside of your web browser, then we have to pay attention to things like the browser cache and how it might affect our interactions with other webservers.
Background
Let's use Perspectives 'Inline Frame' (aka iFrame) component as an example. The iFrame component will render the result returned from HTTP GET requests inside of an instance of Chromium embedded in your View. Lets say you wanted to use an iFrame to render a PDF file you had hosted on some remote webserver. You would plug the URL to the resource into the iFrame "src" property and the iframe would render the file.
https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Inline+Frame
That's great, but then you realize you uploaded the wrong version of the file to the webserver, you upload a new version with the same file name and go check your iFrame to see the change. You might be surprised to notice that the original file that you referenced is still being shown in the iFrame even though the file on the webserver had been updated. This is a result of the HTTP Cache in action. If you want to learn more about HTTP Cache then feel free to click here.
Workaround
The simplest way to fix this issue is to clear the cache but that's not always possible. You could rename the file, but then you have to update the "src" property in the Designer to point to the new URL for the resource being served - not fun! Fortunately, we can trick the browser into thinking we are visiting a new URL, thereby bypassing the cached resource and pulling in the new file instead.
Let's add a pointless URL parameter, which the webserver hosting the file will likely ignore: set the iFrame src
to an expression binding whose expression is:
'http://YOURURL?timestamp=$' + floor(toMillis(now())*0.00001)
whereYOURURL
is the webserver address to the resource in question.
NOTE: You can adjust the "0.00001" value in the expression to an update rate that works for you. The example will update once every 100,000 milliseconds.
Comments
0 comments
Please sign in to leave a comment.