How do I disable cache in Safari 11.0? - safari

I updated Safari today to 11.0 and the 'disable cache(s)' menu item (under Develop) is missing. Anyone know the new way to effect this?

As Adam has answered there was information about disable caches added to the release notes, and I've updated my answer accordingly:
For a one-off, you can use ⌥⌘R on the page to reload from origin or ⇧⌘R from Web Inspector.
For a more permanent solution, you can tell Safari to ignore cache when loading resources by opening Web Inspector then going to the Network tab and setting the icon in the top right (it turns blue when active).
After experimentation with the option in the Network tab, it doesn't appear to behave as documented in the release notes:
The setting appears to persist until manually disabled, even when quitting Safari.
Caching appears to be disabled for all pages, not just the inspected one.
Web Inspector didn't always need to be left open.
Resources served from localhost are sometimes still served from the memory cache, even if caching is disabled in the Network tab. Restarting Safari seemed to clear this behaviour.
Safari Technology Preview Release Notes (Release 27)
Browser Changes
Added a “Reload Page From Origin” alternate menu item to the View menu. This action reloads a page without using cached resources.
Removed the Option-Command-R (⌥⌘R) keyboard shortcut from “Enter/Exit Responsive Design Mode” and mapped it to “Reload Page From Origin” instead.
Removed the Disable Caches menu item in the Develop menu. The equivalent functionality is now available through Web Inspector’s Network tab.
Web Inspector
Added “Disable Caches” toggle in the Networking tab that only applies to the inspected page while Web Inspector is open.
Safari 11.1
The appearance of the icon has changed slightly in Safari 11.1:

It looks like (according to the “Safari Technology Preview Release Notes”) that the only way is to open the “Web Inspector” and go the the “Network” tab, and click the small button to ignore the resource cache.

From my testing on Safari 11.0.3, you should restart Safari after toggling "Ignore the resource cache when loading resources".

Related

How to persistent background page in Safari extension

I used xcrun safari-web-extension-converter to convert my chrome extension to safari extension but it built with this warning
Warning: Persistent background pages are not supported on iOS and iPadOS. You will need to make changes to support a non-persistent background page.
Also when using it on safari, it is showing these errors:
Extension errors in safari
How can I debug the errors in the extension? I'm not sure about the error but the persistent page warning seems to be a good place to start with. While searching for it in google, all I got is results for non-persistent background pages.
Do let me know if any more information is required.
PS:
The extension option in the "develop" menu of safari is also disabled due to service_worker failed to load error.
From WWDC21-10104:
The background page is a web page that the browser loads to run your
extension's background script. And this page allows your extension to
handle events sent by the browser or other parts of your extension.
But keeping this page loaded has a performance cost. It can use memory
and power as if you were keeping one more tab open and running for
every enabled extension. Keeping all these pages loaded all the time
can be pretty wasteful. But you can make a background page
non-persistent, which means the browser will only load it when your
extension actually needs to do work, and the browser can later unload
that page when it's been idle for some time. That way, the performance
cost is only paid while your extension is doing something useful. This
is important because background pages must be non-persistent on iOS,
where system memory and battery life are especially at a premium. The
web extension templates in Xcode already come with a non-persistent
background page, so they're ready to run on iOS. But if you have an
existing extension that uses a persistent background page like Sea
Creator did, you'll need to change it to be non-persistent. And you
can do that by adding that "persistent:" False key in the background
section of your manifest.
So you can solve it by adding this to your manifest.json:
"background": {
"scripts": [ "background.js" ]
"persistent": false
}

How can I make Safari not use a cached version of a page?

In Safari 13.1 on MacOS 10.15.4, I have a page cache that seemingly can't be cleared.
I'm working on a site, served at localhost. When I load the page, I can see in my server logs that Safari requests the page, but it ignores the response and displays an outdated version of the page.
If I close the web inspector, the current version of the page loads, as expected. If I re-open the web inspector, the cached version loads.
I've tried:
Normal page refreshes
Going into the Network tab of the web inspector and toggling the "Use the resource cache when loading resources" button
Clicking the "reload" button in the inspector
Pressing "option + command + r" as that button's tool tip suggests, which is supposed to "reload page ignoring cache"
Develop -> Empty Caches
Quitting Safari and opening it again
Nothing helps.
In the Network tab of inspector, the request for the main page shows "(inspector override)" in the "Transfer Size" column, which seems to confirm that it's using some kind of cache.
How can I get Safari not to use a cache for this page when the web inspector is open?
Get Rid of the "Local Override"
The message "(inspector override)" in the "Transfer Size" column of the web inspector's Network tab indicates that a local override is set.
Also, I hadn't noticed that the page's icon was inverted in the Network tab, as that page says.
Without override:
With overide:
When a local override is set,
[Web inspector will] intercept the network activity and replace it with a local override, allowing for quick local testing without having to modify anything on a server.
When Web Inspector is open, network requests made by the inspected page that match the URL of a local override will instead use the the response content and MIME type, response status, and response headers from Web Inspector, rather than from the network or memory/disk cache.
https://webkit.org/web-inspector/local-overrides/
In my case, I did not know about this feature (which is actually pretty cool!) and apparently had created an override by accident.
To remove a local override, go into the Sources tab of the web inspector, find the "Local Overrides" section on the left, and either uncheck the local override for the page in question or right click it and select "Delete Local Override".

Breakpoints in Safari dev tools get enabled automatically

Each time I load a page with Safari dev tools opened (no matter which tab), some breakpoints get triggered and I get redirected to the Sources tab with the message "Debugger Paused".
The problem is that I didn't set any breakpoints, at least, intentionally, and these redirects don't let me review the source code or load webpages properly.
Even if I disable them, they get re-enabled as soon as I reload the page. I'm failing to understand why this happens.
I see two breakpoints in the Sources tab: All Exceptions and Uncaught Exceptions, but they don't seem to be enabled.
Unfortunately, I couldn't find how to disable the debugger or locate those exceptions. There are no options to do that in the context menu if I right-click the "Debugger Paused" message, disabled exceptions in the Sources tab or Safari settings.
Has anybody come across similar issues or know how to fix that behavior? Any help is much appreciated. Thanks!
Safari 13.1
macOS 10.15.4
Here's how it looks like
You click "+" next to the Breakpoints, then you click All Requests. And then it will appear in the list and is enabled by default. You click disable - VIOLA! See the attached image.

Chrome dev tools site gets stuck in mobile view when exiting emulation mode

When using chrome dev tools to emulate mobile devices, sometimes when toggling emulation from mobile back to desktop the user agent spoofing gets stuck in mobile. I've tried hard cache reset, closing browser completely, restore to default.... but anything I do the site still renders in mobile (even when emulation is turned off).
This happens in Canary, beta, and regular Chrome.
Also a note i've only seen this happen in Sharepoint.
Anyone know how to resolve? Nothing seems to get the dev tools to change user agent back to default when exiting emulation.
Have you tried deleting your chrome settings?
Windows: C:/Users/%username%/AppData/Local/Google/Chrome/User Data
Mac OSX: ~/Library/Application Support/Google/Chrome/
Ubuntu: ~/.config/chromium/
Also make sure you aren't ZOOMED! Gets ya everytime
I ran into this same problem previously when using dev tools in Chrome to look at mobile resolutions that got me permanently stuck in mobile for SharePoint only. I solved it originally with the recommendation above of deleting my Chrome settings folder, however, that meant I had to sign in again, sync my extensions, etc.
After forgetting that this would happen again, I ran into the same issue, but this time I discovered that if you append the following to your SharePoint URL it will reset this back to non-mobile. I verified that it is not temporary as I have closed my browser, reopened, visited SharePoint, and it still loads in desktop mode.
/?mobile=0
So, you would use your site url, e.g. https://siteurl/?mobile=0
Weird, this just started happening to me. It persists in new tabs and new windows. Only fix is to open DevTools and switch to Responsive mode and then pull it way out. As soon as I turn off Responsive / Mobile view, Chrome snaps right back to a mobile view by default (appears to be iPad size).
The solution for me (so far) was to quit Chrome and open it back up.

Safari 5.1 unloading tabs from memory

Well, it seems Safari 5.1 at least on Lion which is what I'm using now decides to unload tabs from memory as it deems it necessary.
The big issue with this is sites that display ajax alerts or ones that have chats as for example GMail. I was having 2 conversations on Google Talk right in the GMail website and while I was on another tab I noticed the title blinking indicating new messages in my conversations, as soon as I clicked the tab Safari decided to completely reload the page, losing all those conversations (I don't keep logs of those).
It goes without saying that this behavior breaks modern web apps and seems unnecessary on a desktop computer. I understand the necessity of this on iOS devices due to ram constrains though.
Is there any way to disable this "feature", I couldn't find a way to do so. It's that or switching to Chrome or Firefox, but I like Safari.
Thanks.
I think I have a temporary work around. Pages on my site — petersonguides.com — periodically reload the tab in Safari 5.1. Ordinarily this wouldn't be a big issue, but I have a video that plays in a FancyZoom box and it can't get all the way through without the tab being refreshed.
I tested with Chrome and it doesn't cause the same tab reload behavior, so I'm sure it's a Safari 5.1 problem.
I have JavaScript and PHP on the home page and I thought there might be a conflict, so I started pulling things off and retesting with the video. The last thing I checked was removing the Google Analytics script. That fixed the problem.
I tried bumping up the Database Storage amount - per the previous answer - but that didn't have any effect.
I am having trouble with Pandora (Flash) not advancing songs in a background tab. As a quick-and-dirty test, I went to Preferences > Advanced > Database storage and popped it up from 5MB to 500MB. Flash is still very unstable, but now songs are advancing in the background. I don't know if this will work for you but you might give it a try.
Safari 5.1 | OS X 10.6.8
The reloading of tabs in the background is a feature of Safari 5.1 on Lion. There is currently no easy way to get around this. The only way possible at the moment involves disabling the multi-process window feature:
Enable Safari's Debug menu by typing in Terminal.app, restarting Safari afterwards:
defaults write com.apple.Safari IncludeInternalDebugMenu 1
From the new Debug menu in Safari, select Use Multi-process Windows to remove the tick before it and deactivate this feature.
While this prevents tab reloading in the background it will disable extensions and gestures in Safari. But it can be easily activated again via the Debug menu.