Kevin Sylvestre
Kevin Sylvestre

Reputation: 38012

Simulate Offline Mode for HTML5 Cache Testing

I have an HTML5 application that requires offline support. For running the application, I use a local Apache server. I am trying to figure out what the best way is to simulate offline mode.

Currently, in Firefox I disable my Air-Port to simulate offline mode, but this is a pain.

Any suggestions? I am open to using other browsers, if a method exists that doesn't require turning off my Internet.

Upvotes: 56

Views: 32037

Answers (5)

CT0
CT0

Reputation: 21

Seems that in Firefox 112.0.2 (64-bit) it is only available in File -> Work Offline. ...Show menu bar with "File" in it on Windows with the ALT key. I can confirm it applies to all tabs, not just the one being debugged.

Upvotes: 2

Richard Williams
Richard Williams

Reputation: 2242

The other answers are out of date. The only place this appears in Firefox v92 is under

File > Work Offline

The File menu can be accessed in the top left of Firefox by pressing the ALT key.

Be warned that this does not prevent traffic from "localhost" loop-back itself, unless you additionally turn on

network.disable-localhost-when-offline

preference in about:config.

Bugzilla issue: Add option to disallow connections to localhost while in offline mode.

Upvotes: 42

David
David

Reputation: 18271

For Firefox
☰ (hamburger menu)->More->Work Offline

Google Chrome doesn't appear to have this feature

Edit: Also, another alternative is slightly more time-consuming to setup in the beginning but might be worth it. For Firefox/Chrome there should be proxy plugins, set up a fake/bad profile for each so that you proxy to something that doesn't exist... like 127.0.0.20:8080. After that you can switch the proxy setting on and off to emulate a full-stack test.

Upvotes: 46

Michael McGinnis
Michael McGinnis

Reputation: 1019

For Firefox, from the ☰ (hamburger menu), choose Web Developer > Work Offline.

For Chrome, open DevTools and select the Network panel. Throttling is set to Online (Disabled) by default. From the dropdown menu, you can choose presets Fast 3G and Slow 3G, but to simulate Offline Mode, you want to choose Offline.

Upvotes: 6

Deletescape
Deletescape

Reputation: 353

In Chrome you can open developer tools switch to the network tab and set throttling to offline

Upvotes: 17

Related Questions