14

Whatever I browse on the Internet, whatever page, is stored in the browser cache on my HDD. The browser cache is stored in the Temporary Internet Files folder on the C drive on the HDD. But was it also stored temporarily (at the time when I browsed it) in RAM, but now overwritten?

That is, does RAM have anything to do with the browser cache and the Internet pages I visit?

  • 4
    Lots of very useful/educational replies below give you the technical answer to your question, but I wonder whether you're asking for another reason, perhaps out of concern for whether someone can steal or track what you've done on the internet. If that's the case, please say so. – Steve Rindsberg Nov 27 '20 at 20:06
  • 1
    @SteveRindsberg As I said before (now the comment is moved to chat), I am asking for acquiring general knowledge as I know there'll be a time when I'll sell my PC, and I do not want the buyer to be able to peek into my internet history. I got the confirmation from all of you that it is safe to let go RAM, and only HDD keeps those privacy things. Thank you once again. – Yashveer Singh Nov 28 '20 at 6:53
  • 3
    @YashveerSingh information is lost from RAM every time it loses power. RAM is volatile memory. If you sell the machine without the hard drive, the buyer won't be able to retrieve any information from the RAM unless you give it to them powered up and they take it away that way – benxyzzy Nov 28 '20 at 14:04
  • 1
    @benxyzzy Thanks – Yashveer Singh Nov 28 '20 at 14:51
  • 1
    @YashveerSingh No problem. Just for completeness, a computer in "sleep" mode counts as powered up – benxyzzy Nov 28 '20 at 15:03
30

In order to show images, text and dynamic elements of web pages all of the data you download has to be operated on by the CPU, processed, decoded and marshalled into a layout, and then pushed out to display, probably that by the GPU.

In order for those devices to do anything at all they need the data to be in RAM. The CPU might be able to use instructions to access hard disks and network devices, but the root instructions pull data from RAM into CPU caches, to then be worked on by the CPU cores.

Practically everything you do on a computer uses the RAM. Device to device DMA across PCIe might avoid RAM, but if you are looking at the end result of something then it, or at least some representation of it, went through your RAM.

For an example of what I mean by that last part look at hardware video decoding. What you see is decoded video frames, the actual video downloaded from the internet will be encoded and compressed. You download compressed video, your CPU copies it to the graphics device memory, and your graphics device decodes the frames in its own memory. Whether that memory is dedicated GPU RAM or your system RAM depends on your whether your GPU is dedicated or integrated into your CPU.


To clarify your comments, RAM has absolutely no persistence. It requires power to retain its state and is completely different from hard disk and other storage memories. I've written more about that topic over at What happens to the content of RAM when a computer turns off?

  • Comments are not for extended discussion; this conversation has been moved to chat. – DavidPostill Nov 27 '20 at 16:40
  • 1
    Device-to-device DMA is using the RAM on the devices (but not the main RAM) – user253751 Nov 28 '20 at 13:16
3

In a very literal sense, what you see on the screen (each individual graphics pixel, not text) is always stored as an image in RAM and then cyclically read from it when it is displayed 60 times a second or so. With a dedicated graphics adapter these days the RAM consists of dedicated (and faster-than-average) chips on the adapter; with integrated graphics, like on business notebooks, the graphics engine may use some of the general RAM.

In a less literal sense, it is likely that both the HTML received from the server as well as an abstract model of the web page — the result of parsing the received HTML — are in memory as well.

The interactions between RAM and hard disk on modern operating systems are both ways: The system may decide to keep parts of the hard disk contents in memory for a while ("cache" it for faster repeated access); and it may decide to "swap" data to disk which a program holds in what it thinks is "memory" because it hasn't been accessed for a while and there is more urgent data to hold.

Therefore it is, at the end of the day, not really relevant to your question whether a browser tries to hold everything in memory or not: The operating system is free to handle memory behind the applications' back the way it deems best, and on a system which is not RAM-starved it is likely that the currently displayed web page is in RAM at all three levels of abstraction.

3

In addition to what the previous answers mentioned, virtually anything on your hard drive was, at least at some point, also in your RAM. Writes to (and reads from) disk virtually always use what is called Direct Memory Access (DMA), where the CPU commands the DMA controller to transfer a block of memory between some device and RAM. Virtually all disk accesses on modern computers happen this way, where the CPU will issue a command to transfer blocks of data from the disk to RAM or from RAM to the disk.

With DMA transfers, the CPU just gets an interrupt when the process is complete. The reason this is done is so that the CPU is not tied up during the transfer and can be busy doing other things (or else can be sleeping and not wasting power.) Virtually all I/O and storage devices (including even the RAM, but especially the disks) are much, much slower than the CPU. While we're still talking about relatively small fractions of a second, the time it takes to transfer a block of data from RAM to a hard drive may as well be an eternity from the CPU's perspective. So, allowing the CPU to just command the process to start and get an interrupt when it's done saves tons of time that can be used for other useful purposes on the CPU.

When you loaded a webpage in your browser, the Ethernet controller would have placed the data coming from the website into your RAM, probably still in an encrypted format. From there, it would be decrypted into another RAM buffer. The browser would generally use the buffer already in RAM to display the page, but then also copies it out to disk using DMA so that it can load it from there again if it needs that resource again instead of having to download it from the Internet again.

You can also be virtually guaranteed that anything currently being displayed in your browser is also currently in RAM. In order for it to be displayed, it will be, at the very least, in its final rendered form in video RAM, though the original HTML, javascript, image files, etc. are likely also still in the main CPU RAM as long as the page is still actively open.

3

To complement other answers: in a sense, a modern CPU can ONLY operate with data in the RAM. To all the other devices (HDD, SSD, network adapter, sound card, whatever) it can only say "hey, take this data from this spot in the RAM" or "hey, give me some data and place it in this spot in the RAM". And when the device is done, it notifies the CPU, and then the CPU goes to the RAM and does whatever else it needs to do with that data.

Well, in theory there is that old "PIO" method (where a device sends all the data directly to the CPU, byte by byte) but that really isn't used much these days because it ties up the CPU and is generally very, very slow.

Some devices (most notably video adapters, but many others as well to a lesser degree) also have their own internal RAMs. The CPU may or may not be able to access those directly as well.

But to answer your original question - as other have already stated, yes, the webpage will DEFINITELY be stored in your RAM. And that's also going to be the version you will see. All the other places that it might be - browser cache, network adapter, whatever - are only stepping stones before the webpage gets loaded in your RAM. That's it's final destination, before the CPU works upon it and converts it to graphical pixels that it sends to the video adapter, which in turn sends it to the monitor. (Roughly speaking; there's some shortcuts there to make things faster, but in principle that's what is happening).

  • Even with the really old PIO system, the CPU would usually store the data in RAM first, then process it. – user253751 Nov 28 '20 at 13:17
  • @user253751 - True, I just mentioned it for the sake of completeness. – Vilx- Nov 29 '20 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.