57

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.

Jason
  • 1,059
4253wyerg4e
  • 541
  • 5
  • 11

5 Answers5

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)
robinCTS
  • 4,407
McFarlane
  • 613
12

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.

robinCTS
  • 4,407
Wildcard
  • 600
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.

robinCTS
  • 4,407
DavidPostill
  • 162,382
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
  • 83
  • 4
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.

robinCTS
  • 4,407