Does saving a web page using Ctrl+S in Firefox make the browser load the site a second time?

57

11

When saving a website for offline reading with Ctrl+S in Firefox, I notice that the download process takes some seconds to finish although the web page is already loaded.

I'm wondering whether saving the web page like that will make Firefox fetch all the content (HTML, images, JavaScript, CSS, etc.) a second time, or whether it will just get it from the already loaded files in the cache.

4253wyerg4e

Posted 2018-08-27T05:39:46.697

Reputation: 541

As I remember, old firefoxes reloaded the page. The answers are for the current firefox. It is since some years so. – peterh - Reinstate Monica – 2018-08-27T10:27:43.937

Could you clarify what you call "the download process"? Even though the resources that are in memory should not be re-downloaded from the network, the browser still has things to do to export all the data in a folder + changing links etc. Also, if the storage disk was paused, it might take some time just to wake it up so we can write to it. But if you are talking about the Library>Downloads panel taking time and showing something like 1.2Mbps, then it might be related to this regression they didn't consider to be a bug...

– Kaiido – 2018-08-28T00:50:50.543

4While other users have already answered this aptly, do note that catalogging such behavior on any software can often be a futile effort unless if a behavior guarantee is provided by the software developers.

And so any answer that is marked as correct should point to the version that it was tested against rather than making a broad assumption about all future and past versions. Good thing that the top answer already has addressed this concern.

I know; nitpicking. – Adnan Y – 2018-08-28T05:32:40.150

Although this looks like, and by all means is a "WTF", reality has it that this was perfectly normal a decade or so ago, not just with Firefox. Don't ask me why, it makes no sense at all. – Damon – 2018-08-28T17:15:51.677

Answers

68

No, it does not trigger a second request.

I just tested it by running a simple HTTP server to log the requests. The server did not receive a second request when saving the website.

  • Tested with: Firefox 61.0.1 (64-Bit) on Ubuntu 18.04
  • Server: SimpleHTTPServer module of python 2.7.15 (python -m SimpleHTTPServer 7070)

Edit:

Commenters asked about different behavior if the server is sending "no-cache" headers. I tested it with Pragma: No-Cache and Cache-Control: No-Cache and the result stays the same.

The code I used to do the test (via this answer):

#!/usr/bin/env python
import SimpleHTTPServer

class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_my_headers()

        SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)

    def send_my_headers(self):
        self.send_header("Pragma", "No-Cache")
        self.send_header("Cache-Control", "No-Cache")


if __name__ == '__main__':
    SimpleHTTPServer.test(HandlerClass=MyHTTPRequestHandler)

McFarlane

Posted 2018-08-27T05:39:46.697

Reputation: 613

11

No, it doesn't.

I've just tested this without any code by disconnecting my computer from the Internet and then saving an already-loaded webpage.

It worked. You can do the same test yourself.


Granted that the behavior could be different if the computer is online or offline, but the current top answer shows a more in-depth test. I just think it's still valuable to have a simple test.

Wildcard

Posted 2018-08-27T05:39:46.697

Reputation: 401

11There's so many combinations of Expires, Cache-control, Pragma, and possibly other headers, that "not in this single case" certainly doesn't mean "never". Without looking at the source code, I wouldn't bet on anything. – Guntram Blohm supports Monica – 2018-08-27T20:03:28.547

5@GuntramBlohm, absolutely right. On the other hand, if the simple test failed, then you can definitively conclude that Ctrl-S won't always work without sending an additional request to the server, even if it might sometimes do so. So the simple test still has value; I was surprised no one else had mentioned it, so I did. – Wildcard – 2018-08-27T20:45:43.703

7

Does saving a web page (ctrls ) make Firefox fetch all the content a second time?

This is easily tested using Firefox's developer tools.

  • Open the tools and click the "Network" tab.

  • Save the page

You will see there is no extra network traffic generated.

DavidPostill

Posted 2018-08-27T05:39:46.697

Reputation: 118 938

50I doubt that we you can rely on the developer tools in this case. It only shows traffic from a single tab and I don't think that the download is running in the context of that tab. I think by your reasoning using "save as" from the context menu on a link that you haven't visited should show up in the network tab - but it doesn't. – kapex – 2018-08-27T08:48:25.890

@kapex Understood. But save as on an unvisited link is not what is happening in this case. – DavidPostill – 2018-08-27T09:08:08.710

5@kapex I just unplugged my internet connection and was still able to correctly save a page ... – DavidPostill – 2018-08-27T09:34:12.003

11I'm not doubting that it uses the cache, I'm just doubting that the developer tools can be used to proof that. I would expect both "save as" and "save page" to behave in the same way but of course there could be differences. So here's another idea: If we disable caching in the developer tools, using ctrl+s should certainly show up in the network tab, but again it doesn't. – kapex – 2018-08-27T09:36:59.260

1You'd have to use the Browser Toolbox, which shows all network requests from the browser, including internal ones not tied to a specific page. – Neil – 2018-08-28T07:51:32.380

The best way to check this would be with something like fiddler, intercepting all network activity... – Laurent S. – 2018-08-29T11:55:36.750

2

Contrary to the other answers, Firefox 59.0 does download a second time for (in my testing) images, but not HTML files.

I loaded an arbritrary image (https://cdn.shopify.com/s/files/1/1613/3867/products/GS_cat_feeding_reminder_forget_someone.png?v=1520745318) and used ctrl+s to save it.

wdkmaaeo

Posted 2018-08-27T05:39:46.697

Reputation: 43

1

Possibly.

CSS has a @media selector. It allows the CSS to use different definitions depending on what kind of hardware is being used to display the page - printer, screens of different sizes, etc.

CSS can also directly request image files (bullet point images, background images).

Now if Firefox downloads just what's needed for the current hardware when displaying the page, but downloads everything when saving to disk, then you can have extra requests.

Caveat:

This is just the first half of a practically useful answer; the second half would be testing this scenario. Unfortunately, I'm running out of time, so I'll accept any edits or comments if somebody can report repeatable test results.

toolforger

Posted 2018-08-27T05:39:46.697

Reputation: 111

Nope, all CSS files are downloaded, just not parsed :) – Martijn – 2018-08-30T07:38:03.200