How to empty browser cache

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

How to empty browser cache

Post by skindoc4 » Sun Jan 05, 2020 6:06 am

I am attempting to use Livecode to learn web programming by writing a web application. I can set up file saving and editing with a pre-prepared glossary in Livecode. I am quite new to web programming so I am writing HTML, CSS and JS almost line by line which I need to test as I go. Livecode, of course, provides a very convenient environment for the manipulation of these files. I have been using the built-in browser to view the output.

However, I cannot find a way of clearing the browser cache so that I can see the changes made to the source file for the web application. The cache is clearly an attribute of the browser window but I do not know to access end destroy its contents. The cachedURLs function returns empty yet the browser goes back to the first opened version of the file, not the altered version.

I am on a Mac. The work around at the moment is to default to Safari with the development menu and empty the cache manually - ugh.

Does anyone know how the browser cache can be emptied via script in Livecode?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to empty browser cache

Post by richmond62 » Sun Jan 05, 2020 11:12 am

I am attempting to use Livecode to learn web programming by writing a web application.
That is a bit odd.

LiveCode's strengths lie in building desktop (and handheld) apps.

tomBTG
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Fri Nov 25, 2011 6:42 pm
Location: Kansas City

Re: How to empty browser cache

Post by tomBTG » Sun Jan 05, 2020 5:37 pm

Check out UNLOAD in the LC dictionary. I use it in desktop apps to clear the cache of previously downloaded web files accessed by my app.

Hope that works for you.

-- Tom Bodine

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: How to empty browser cache

Post by skindoc4 » Mon Jan 06, 2020 2:20 pm

Hi Tom

"Unload" only works for items to which the "Load" command has been applied (I checked "Unload" thoroughly prior to the post). It does not work for web pages placed in the browser ie. I can have a page displayed in the browser and at the same time the "cachedURLs" function returns empty. I can send a different page to the browser and have it display, make a change to the source of the first page, resend the first page to the browser but the display changes to the cached version of the first page, not the new version. It is the cache that the browser uses under these circumstances that I would like to access and empty but I do not know how. The only way to empty it that I have found is to quit livecode - not very practical.

There is a setting in Safari preferences that empties the cache so that the new version loads every time. This works but it is not as neat as being able to everything within livecode.

Hi richmond62

Not that odd really. Since I have been writing applications in hypercard, metacard, rev and now livecode for a long period of time, what better place to write an application (for my own use now that I am retired) which facilitates dealing with the arcane mess that is HTML, CSS and JS. There are some excellent editors (Atom for example) but I cannot tweak them to do all of the things I want in the way that I can with livecode. After 35 years programming in this environment (but never for the web) I think I have become familiar with livecode's strengths and weaknesses. Do you have any suggestions for solving the problem?

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: How to empty browser cache

Post by SparkOut » Mon Jan 06, 2020 3:02 pm

I have heard of a trick (I can't remember who should be credited, I have a vague recollection of seeing it on the mailing list) to force a refreshed view of a revisited page by appending a fake anchor point to the url, using the milliseconds as the anchor ref.

thewebsite.com/content.php#123457 should display the current content of thewebsite.com/content.php in preference to what might have been cached when thewebsite.com/content.php#123456 was visited.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to empty browser cache

Post by jacque » Mon Jan 06, 2020 5:14 pm

I was just going to suggest the same thing. I generally use a "query" construct on the theory it's more likely to force a reload :

www.domain.com/page.html?s=128394i7282

It doesn't matter what's in the query string as long as it's unique to the session. The seconds is convenient for that. The idea is to trick the browser into thinking it needs to fetch an updated copy because the URL is new.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: How to empty browser cache

Post by skindoc4 » Tue Jan 07, 2020 3:32 pm

Thank you Sparkout and Jacqueline. I'll try this and see how I get on.

Cheers

Alex

Post Reply

Return to “Internet”