Live data from Hacker News

Ask HN: Why does 'View Source' issue a new HTTP request?

news.ycombinator.com

61–70 of 97 posts

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#61
post #32

Earlier quoted context omitted.

Yes, but if you have more than enough memory, then that's no problem. So, the browser should load the HTML page into a part of memory that can be discarded by the OS if the OS needs more memory. Actually I think it is strange that no such memory API exists in Unix. EDIT: Anyway, storing it in the browser's file cache would also do the trick, I suppose :)

Isn't that one of the issues nowadays, that people have the attitude "we have enough memory" and thus don't tend to care about optimizing for memory usage anymore. Your suggested solution, about discarding when memory is needed, solves this problem. But it solves a problem that would be created by needlessly storing a lot more data than needed. So it's a solution to a problem that was not a problem to begin with. But…

100kb * 100 tabs is 10MB. I'll take my chances.

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#62
post #58

It's a bug: https://bugzilla.mozilla.org/show_bug.cgi?id=307089 Or, it's a memory saving feature. To implement "View source from cache" requires keeping around the raw page HTML, which you might not otherwise need after parsing - except you probably will for all the developer tools to work, so this probably should just be considered bug.

Why keeping the original source in memory? Why not saving it to disk?

Maybe because it would prematurely age SSDs?

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#63
post #60

Earlier quoted context omitted.

Am I in some parallel universe here ? We are talking about hundreds of KBs of memory total which is nothing and if it's a worry for mobile devices we have the disk. It's not a feature that demands instant performance.

But who does this feature help exactly? A _tiny_ number of users. Chrome is currently using over 3GB on my machine. Anything they can do to trim that without affecting performance is worth it to me.

3GB is how much memory the _rendered/executed_ source code takes. The source code is nothing. Store it LZ4 compressed in memory and it's less than a rounding error.

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#64
post #51

Earlier quoted context omitted.

> It's not a feature that demands instant performance. Hence it's acceptable to request the document from the server when opening 'View Source'.

No, because when you want to view the source you mean to view the source of this very document, not the source you'd get by asking to reload the page, it is often different.

If you want to see the page as it's currently being rendered, looking in the developer tools seems more relevant anyway.

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#65
post #52

Earlier quoted context omitted.

> "we have enough memory" Your phone is in disagreement.

My phone has a quite insane 3 GB of RAM.

My phone also has the insane 3GB of RAM, but last week Chrome killed Spotify and vice versa (music stopped playing) as soon as I switched apps. Sadly 3GB is not enough for Android and todays apps.

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#66
post #32
post #27

Earlier quoted context omitted.

The browser would have to save the source text for EVERY tab it opens, regardless of whether you view source or not. That seems more onerous than making a separate request for the source code every once in a while.

Yes, but if you have more than enough memory, then that's no problem. So, the browser should load the HTML page into a part of memory that can be discarded by the OS if the OS needs more memory. Actually I think it is strange that no such memory API exists in Unix. EDIT: Anyway, storing it in the browser's file cache would also do the trick, I suppose :)

> So, the browser should load the HTML page into a part of memory that can be discarded by the OS if the OS needs more memory. Actually I think it is strange that no such memory API exists in Unix.

It is more tricky then you would think to determine what "needed" memory means. Does the OS need disk cache? Or the content of memory mapped files?

It's not unlikely that you currently have some process active which has memory mapped a huge file. Does it need the content? Who knows.

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#67
post #32

Earlier quoted context omitted.

Yes, but if you have more than enough memory, then that's no problem. So, the browser should load the HTML page into a part of memory that can be discarded by the OS if the OS needs more memory. Actually I think it is strange that no such memory API exists in Unix. EDIT: Anyway, storing it in the browser's file cache would also do the trick, I suppose :)

Isn't that one of the issues nowadays, that people have the attitude "we have enough memory" and thus don't tend to care about optimizing for memory usage anymore. Your suggested solution, about discarding when memory is needed, solves this problem. But it solves a problem that would be created by needlessly storing a lot more data than needed. So it's a solution to a problem that was not a problem to begin with. But…

No this is really not the case of thinking we have enough memory. This is the realization that the static source code of a page is a percentage error compared to the memory overhead of a rendered page. The modern browser are memory hog I would rather they focus on that.

Its also a broken implementation function wise since I have asked for the source of the current page not of a reload.

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#68
post #50

Earlier quoted context omitted.

Why would you need the original HTML for dev tools to work? Maybe there are ones I've never seen but the ones I use are using the DOM rather than the original HTML string.

I showed a few people who have no idea about programming whatsoever how to hack websites to download .mp4 or .mp3 from source code of the website. How would you show them that using DOM...

If there's an audio tag, that element exists in the DOM and has a reference to the url where you can download it. Is this a trick question?

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#69
post #50

Earlier quoted context omitted.

Why would you need the original HTML for dev tools to work? Maybe there are ones I've never seen but the ones I use are using the DOM rather than the original HTML string.

I showed a few people who have no idea about programming whatsoever how to hack websites to download .mp4 or .mp3 from source code of the website. How would you show them that using DOM...

How would you show them that using the HTML source?

You can use dev tools to view the network tab to find whatever URL Pandora is using.

You can use dev tools to find a media elements src attribute.

To see the JavaScript sources... You check the dev tools.

If anything, in the days of JavaScript, the HTML source will missing a few things.

Re: Ask HN: Why does 'View Source' issue a new HTTP request?

#70
post #13

It's a bug: https://bugzilla.mozilla.org/show_bug.cgi?id=307089 Or, it's a memory saving feature. To implement "View source from cache" requires keeping around the raw page HTML, which you might not otherwise need after parsing - except you probably will for all the developer tools to work, so this probably should just be considered bug.

How much memory is saved here? http://www.httparchive.org/interesting.php?a=All&l=Dec%202%2... 52 _kilobytes_ ? Really?

What everyone is missing here is that one in ten thousand users needs this, so why optimize for the vast minority?
Post reply on HN