Clear one specific site from Safari cache?

I’m working on a script that runs a Fluid app to display a local HTML file. The script uses PlistBuddy to write a file url into the Fluid app’s default-settings plist and then runs the Fluid app.

This works the first time I do it, but the trouble I’ve encountered is that Fluid uses the Safari browser cache (at least it seems to), and so it doesn’t open the new file that I wrote into the defaults list; instead it opens the previous file. Eventually it sorts itself out, but only after a couple of launches.

Is there a way to clear out the Safari browser cache for one entry only? I’d like make my script (1) read the existing url in the Fluid app’s settings, (2) delete that entry from Safari’s cache, and (3) write new url into the Fluid app’s settings, before launching the app.

Am I trying to do the impossible?

I suspect your problem is that you have misdiagnosed what’s going wrong. Apps’ defaults are controlled and cached by a daemon – once an app is running, changing the preference file does nothing until the Mac is restarted or the daemon clears its cache. Once an app is running, the preference file reflects the app’s preferences, rather than dictates them.

What you should be doing is modifying the app’s defaults using the command-line tool defaults or NSUserDefaults via AppleScriptObjC.

Thank you again, Shane. That pointed me in the right direction. It turned out that even defaults delete didn’t clear out the previous url entry - but I saw that the previous url was listed in a defaults setting that had the name “sessions” in it. This led me to look again at FluidApp’s defaults file, where I belatedly found an option to disable sessions - which clearly means saved sessions that the app uses when starting up again. When I turned that option off, the app always started up with the current url - and started a lot faster.

Anyone who might be interested in building a Fluid app like this will have no trouble finding further details about Fluid’s “sessions” if they’re interested.

Thank you again, Shane!