Live data from Hacker News

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

news.ycombinator.com

91–97 of 97 posts

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

#91
post #75

Earlier quoted context omitted.

> requires keeping around the raw page HTML Isn't it already in the browser's cache in that state anyway? And if the cache is small, the preservation doesn't even have to be "for all tabs," if the last few pages can be retrieved from the cache nobody would complain that the older ones behave as they behave now -- you typically don't do "I wonder what was the source of the page from yesterday" in this old tab, but eve…

> Isn't it already in the browser's cache in that state anyway? Like disk cache as in Cache-Control? In most cases you wouldn't cache the HTML itself, but in cases where you do then your use case should already work as stated, since for the browser to do otherwise would imply the cache is being intentionally ignored for the view-source request.

> In most cases you wouldn't cache the HTML itself

Why not, at least as long as that's the topmost tab? Wouldn't then the view-source-new-request problem be solved by just using the existing features?

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

#92
post #60

Earlier quoted context omitted.

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.

Yes, I know that, but all of these little inefficiencies add up, and for what? A tiny portion of users who need the developer tools? Not worth it.

This kind of thinking is exactly what leads to our software being as slow or slower than that of two decades ago while running on machines hundreds or thousands of times more powerful.

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

#93
post #50

Earlier quoted context omitted.

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?

Yes, my mother doesn't know what DOM is or why there are so many buttons in devtools. ctrl+u -> ctrl+f -> mp3 is much easier to explain and repeat.

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

#95
I once wondered this, but didn't think much of it. Now seeing the question, it seems quite clear. The DOM+CSS+javascript is pretty much like a computer running a (self-modifying) program. If it didn't do a fresh fetch, then what you'd be seeing is the contents of 'memory' after the program has been running some time. This is useful in itself, so we have Inspect. If you want to see the initial state, the program before execution begins, then you want to View its source(s).

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

#96
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...

Right but then you're talking about viewing the HTML source right? In other words "View Source." I'm asking why dev tools would need access to the original source and not the DOM. It doesn't make sense to save the original source in memory to me once it's been parsed.

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

#97
post #71

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.

You don't typically. One case where you would View Source in addition to using Dev Tools is debugging how the browser is massaging your source HTML into the DOM, for example by inserting missing elements. Validating your HTML mostly addresses this (I'm actually not sure about the example, I would hope the validator at least issues a warning), but isn't something you necessarily want or can do with, for example, user-…

True, though I guess using some HTML validation could improve that. Not sure if is mandatory but I think I've seen some tool complain about its absence.
Post reply on HN