如何在 IOS Safari 上禁用缓存?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9218123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:44:34  来源:igfitidea点击:

How to disable cache on IOS safari?

iphoneiosipadsafari

提问by Dean

Is there a way to disable caching on ipad/iphone? I want to run some automated tests for non-cache experience.

有没有办法在 ipad/iphone 上禁用缓存?我想为非缓存体验运行一些自动化测试。

回答by Collin Allen

I just stumbled across a way to disable cache in Safari on iOS:

我只是偶然发现了一种在 iOS 上的 Safari 中禁用缓存的方法:

iOS

IOS

  1. Open Settings
  2. Navigate to Safari > Advanced
  3. Enable Web Inspector
  4. Switch back to Safari and load a web page
  1. 打开设置
  2. 导航到Safari > 高级
  3. 启用网络检查器
  4. 切换回 Safari 并加载网页

Desktop

桌面

  1. Open Safari
  2. Navigate to Safari > Preferences > Advancedtab
  3. Enable the Developmenu
  4. In the Developmenu, select Your iOS Device Name> The Page You Want to Debug
  5. Press Command-Shift-R to reload while disabling cache
  6. Bonus: This is a full Web Inspector on your computer inspecting a page on your iOS device
  1. 打开 Safari
  2. 导航到Safari > 首选项 > 高级选项卡
  3. 启用开发菜单
  4. 开发菜单中,选择您的 iOS 设备名称>您想要调试的页面
  5. 在禁用缓存的同时按下 Command-Shift-R 重新加载
  6. 奖励:这是您计算机上的完整 Web Inspector,用于检查 iOS 设备上的页面

If you want something more permanent, you'll either have to go the proxy routeor make a UIWebView/WKWebViewwrapper app that disables caching.

如果你想要更持久的东西,你要么必须走代理路线,要么制作一个禁用缓存的UIWebView/WKWebView包装器应用程序。

回答by James Gupta

I could be wrong, but on iOS does putting Safari in Private Browsing mode disable cache?

我可能是错的,但在 iOS 上是否将 Safari 置于隐私浏览模式禁用缓存?

回答by muzzamo

There is a way to effectively disable caching on iphone/ipad/IOS.

有一种方法可以有效地禁用 iphone/ipad/IOS 上的缓存。

Install Fiddler on a windows desktop, and allow remote computers to connect:

在 Windows 桌面上安装 Fiddler,并允许远程计算机连接:

enter image description here

在此处输入图片说明

In IOS, setup a proxy under your wifi connection settings, pointing to to the IP address of the computer you are running fiddler on, and on port 8888 (assuming you haven't changed it from default in fiddler):

在 IOS 中,在您的 wifi 连接设置下设置一个代理,指向您运行 fiddler 的计算机的 IP 地址和端口 8888(假设您没有更改 fiddler 中的默认设置):

enter image description here

在此处输入图片说明

By now, fiddler should be intercepting all web requests your device is making.

现在,fiddler 应该会拦截您的设备发出的所有网络请求。

You can now disable caching from the Rules -> Performance menu in fiddler.

您现在可以从 Fiddler 中的规则 -> 性能菜单禁用缓存。

enter image description here

在此处输入图片说明

回答by Raymond Wang

Doesn't seems like possible. On desktop safari, there is a option to disable cache in developer tools, however there isn't one on mobile safari. I didn't find the option in other browsers like opera neither.

好像不太可能。在桌面 safari 上,有一个选项可以在开发人员工具中禁用缓存,但在移动 safari 上没有。我也没有在像歌剧这样的其他浏览器中找到这个选项。

If you wanna try, you can overwrite a desktop firefox's user agent string and make it a fake ipad mobile browser, and then disable cache. But that will depends on what you want to test and it could not work at all.

如果你想尝试,你可以覆盖桌面 firefox 的用户代理字符串,让它成为一个假的 ipad 移动浏览器,然后禁用缓存。但这取决于您要测试的内容,它根本无法工作。

Hope this helps.

希望这可以帮助。

回答by BG Bruno

In the newest MACOS doesn't work anything to "full reload" content to me. Debug isn't really something pleasure.

在最新的 MACOS 中,无法向我“完全重新加载”内容。调试并不是真正的乐趣。

After connect desktop Apple Safariwith iPhoneor iPad- it should work ALT+CMD+R- but not for me.

将桌面Apple SafariiPhoneiPad连接后- 它应该可以工作ALT+ CMD+ R- 但不适合我。

The newest trick is

最新的技巧是

  1. hold CTRL+SHIFT
  2. and CLICK not touch, to icon "Reaload page"
  1. 按住CTRL+SHIFT
  2. 并单击不触摸,以图标“重新加载页面”

Maybe help someone.

也许帮助某人。

Thx for inspiration https://stackoverflow.com/a/24129161/1347601

感谢灵感 https://stackoverflow.com/a/24129161/1347601

回答by Hal

Using iOS Simulator 9.0 I have been finding that both the Developer - Disable Caches menu item and Cmd-Shift-R reload have both failed to completely bypass the cache for whatever reason. The only thing that worked was to hold shift and press this reload button in the Safari Developer tools:

使用 iOS Simulator 9.0,我发现无论出于何种原因,Developer - Disable Caches 菜单项和 Cmd-Shift-R 重新加载都未能完全绕过缓存。唯一有效的是按住 shift 并按下 Safari Developer 工具中的这个重新加载按钮:

enter image description here

在此处输入图片说明