Safari 16 history caching

Does anyone know of a way to prevent Safari 16 (16.2) from caching history? The only option I can find is to set it to "one day". Of course, I can manually do a 3-click process to clear it after each query. But while this restriction might be acceptable for someone simply browsing the web, it's totally unacceptable for developing web code locally, using "Brackets" on a MAMP PRO local installation.


If Neil Armstrong was a programmer, he'd surely note: "Thats one small step for a man, one giant leap [backwards] for mankind."


MacBook Pro 16″, macOS 13.1

Posted on Apr 20, 2023 7:09 PM

Reply
Question marked as Top-ranking reply

Posted on Apr 26, 2023 10:03 AM

I just tested the following AppleScript that I wrote in 2018 on macOS 13.3.1 and it still works to clear all history and the browser cache on Safari 16.4. You could save it first as AppleScript text (source) and then using option+Save As… as an Application that goes on your Dock. Then it is a one-button click solution to clear up Safari.


Open in the Script Editor, click compile, and run.


-- nohistory.applescript
-- Purges all Safari history, the browser cache, and quits the application if it is running.
-- Update: 2023-04-26, macOS 13.3.1 and Safari 16.4
-- VikingOSX, 2018-07-15, Apple Support Communities, No warranty expresed or implied

tell application "Safari" to activate
tell application "System Events"
	tell application process "Safari"
		set frontmost to true
		-- clear the cache
		keystroke "E" using {option down, command down}
		delay 1
		-- now clear all history
		tell menu item "Clear History…" of menu "Safari" of first menu bar to click
		delay 1
		tell pop up button 1 of sheet 1 of window 1
			perform action "AXPress"
			click menu item "all history" of its menu
		end tell
		tell button "Clear History" of sheet 1 of window 1 to click
	end tell
end tell
tell application "Safari" to if it is running then quit
return


22 replies

Apr 26, 2023 1:11 PM in response to svdrifter

When I run the identical script that I posted earlier on macOS 12.6.5 with Safari 16.4.1, it clears the cache and all history without any error.


In System Preferences > Security & Privacy > Accessibility panel, Script Editor is selected. You can add [+] it and select it in /Applications/Utilities to place it on this Accessibility list. In the Full Disk Access panel, Script Editor is not present. It is present in the Files and Folder panel, and when expanded, Documents and Desktop folders are enabled. There is no entry for Script Editor in the Automation panel.

Apr 26, 2023 7:28 PM in response to VikingOSX

No luck with your suggestions, but thanks just the same. I'm giving it up!


My latest M1 MBP16 isn't worth the bag I carry it in. It took me 11-1/2 months before I could get it to run Safari... at all! I had the same issues with it's two predecessors that I returned to Apple in time for a refund (different models). Despite MANY hours on the phone with SUPPORT, nobody could figure out what was causing the many issues. After 11-1/2 months, I finally came up with the answer myself.


I've been using High Sierra for years, because it's stable and it just works! More importantly, I depended on some very critical 32-bit apps, that I didn't want to give up (and for which there were no upgrades). I've always used Migration Assistant to move data from one computer's TB drive to the next... and always without issue. But there have been many structural changes between High Sierra and the latest OS versions. Apparently, Migration Assistant is no longer smart enough to handle these differences.


Once I figured out that my issues were very similar with all three of the previous laptop purchases, I wiped the system clean and did a manual data transfer from scratch. That solve most of the issues, and after a year of wasted effort and lost development revenue, I now have a system that [almost] works. (OK... not as well as my MBP15 on High Sierra, and not even any faster). My current issues began when I made the fatal mistake of up[dn]grading from Monterey (which I hate) to Ventura (which I despise).


Live and learn (or not). I'm going back to Monterey on this box (which is the oldest OS it can use). Then use it to store and watch movies, etc. I'll continue to program on my MBP15/High Sierra box, until it dies (or until I do, out of frustration).


I'm taking my sailing vessel "Drifter" and sail to the Bahamas (where my only worries are hurricanes). Thanks to all for your attempts to assist.


svDrifter




Apr 26, 2023 8:41 PM in response to VikingOSX

For what it's worth... I've determined that the issue is NOT with Safari's failure to clear the cache, when requested... it's the OS that's responsible! It doesn't matter which browser I use, NONE of them will clear the cache! As such, a correction (or change) composed of only one character or variable, typically takes at 10 minutes or more before you can see the change!


How does one effectively program under those conditions?!


Apr 27, 2024 3:17 PM in response to VikingOSX

It looks like I missed this question, "VikingOSX". Yes, I did try your suggestion, although I used KeyBoard Maestro to do so, as I use it for many similar tasks. While it does, indeed, make "implementing the task" somewhar quicker, it does nothing to make it "more effective"... at least not with regard to my issue.


==============================================

Before I continue, let me restate the problem...

I'm currently redesigning an web application that I first built 22 years ago, that creates a very lengthy document, which is ultimately converted to a PDF printout (typically 150-170 pages). It first requires a series of very complex mathematical calculations, from which it creates a very detailed report by piecing together thousands of paragraphs, images and other components, based on the calculations performed. No two reports are ever identical, unless they were both created using totally identical input! I'm in the final process of working out the CSS for printing, which is similar to, but different from, the CSS for on-screen display. This typically requires making a few minor changes to the extensive stylesheet (or to the text document itself), and then redisplaying the entire document onscreen. (Typically it needn't be "Printed to PDF" until later, but sometimes it is.)


The problem I'm finding in Safari (and other browsers) is that I can NOT efficiently clear the "History" and/or "Caches" in order for the changes to be viewed. The "Safari" menu has an option: "Clear History..", and the "Develop" menu has an option: "Empty Caches". Both of these work occasionally, but neither option works consistently, nor predictably. As such, I spend a couple of seconds modifying the CSS and several MINUTES trying to see the results. I sometimes "Clear History" and "Empty Caches" numerous times, without effect. I even tried closing the browser (and all opened support windows), which works once in a while, but again... not consistently, nor predictably).

==============================================


Back to the Present... I have indeed used the commands: "Safari/Clear History..." and also "History/Clear History..." and "Develop/Clear History", using all offered conditions (when available). None of these options, however, predictably perform the task. I suspect that these requests are offered for security, and not for expediency. Granted, it's unusual for anyone to have need to reload a 150+ page HTML document in it's entirely, simply to review the effect. But when you're writing an HTML document freehand line by line in PHP, using only "Brackets" as a code editor (and including jQuery, CSS, etc.), it really helps to immediately see the results of live changes.


I was using Monterey when I first discovered this issue. I am now on Sonoma 14.3.1 and I hesitate going any higher, as each new OS version comes with too many new bugs and absolutely no new features, for which I have a need.


I don't really expect any solutions, but thought it would be a good idea to "stir the pot" (rather than hang a whole new batch over the fire). If anyone has any suggestions, I'd love to give it a try.


Thank you!








This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Safari 16 history caching

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.