Live data from Hacker News

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

news.ycombinator.com

21–30 of 97 posts

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

#21
I wish View Source were more flexible. I would like:

* Raw: a view of the actual body as sent in the response. Although I'm not aware of the current situation, at least some browsers used to subtly alter what was sent, even for View Source (possibly related to validity corrections). I want a guarantee that what I'm viewing is what the server sent.

* View source as it is today (with a good common understanding of what that means), but a bit more powerful. Give me a cursor so I can copy from the keyboard, for crying out loud! Maybe even let me edit the source so I can work with static pages more easily.

* Something in-between View Source and DOM inspector. E.g. the original source, guaranteed to be untouched by javascript, but cleaned-up for easier reading (given that the source returned by many websites nowadays is practically unreadable (take a look at this page, for example). Reformatting (where possible), maybe automatic expansion of any base href, consistent ordering of attributes, highlighting of errors, etc.

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

#22
post #3

I'm not exactly sure why browsers do that, but I suspect that's due to caching. However, I would suggest that you use "Inspect element" and open up dev tools - this way you will see DOM exactly as it is rendered.

> I suspect that's due to caching.

Shouldn't caching have the opposite effect? i.e. it's treated as a new resource but no new http request is needed because it's in the cache..

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

#23
post #12
post #9

Earlier quoted context omitted.

You can still do that with the inspect menu; if you look at the network history in Chrome, you can see the headers sent, the headers received and the body sent / received.

> You can still do that with the inspect menu; if you look at the network history in Chrome, you can see the headers sent, the headers received and the body sent / received. That only works if you have it open before the page loaded. It doesn't save information about network requests that occurred before the inspector was opened.

It would be handy if it did though since I continually forget to open inspector before the request.

I'd love a "I'm a developer, store all the things!" setting

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

#24
post #2

I usually have Fiddler running constantly in the background. If a page is slow to load and I want to see the HTML, I would find the actual HTTP request in fiddler and grab the HTML that way. Alternatively, the element inspector doesn't re-issue the request, but it will show the compiled HTML, so after DOM augmentation etc

Is there anything comparable to Fiddler for macOS? I heard you can run it in VM but that's just too much brute force for me.

https://mitmproxy.org/ or https://charlesproxy.com/

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

#25

I wish View Source were more flexible. I would like: * Raw: a view of the actual body as sent in the response. Although I'm not aware of the current situation, at least some browsers used to subtly alter what was sent, even for View Source (possibly related to validity corrections). I want a guarantee that what I'm viewing is what the server sent. * View source as it is today (with a good common understanding of what…

Isn't a debugging proxy (like Fiddler) a good choice for the first of those?

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

#27
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?

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.

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

#28

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

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

#29

I wish View Source were more flexible. I would like: * Raw: a view of the actual body as sent in the response. Although I'm not aware of the current situation, at least some browsers used to subtly alter what was sent, even for View Source (possibly related to validity corrections). I want a guarantee that what I'm viewing is what the server sent. * View source as it is today (with a good common understanding of what…

Isn't a debugging proxy (like Fiddler) a good choice for the first of those?

[deleted]

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

#30

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.

Couldn't you reconstruct the source from the internal dom representation anyway?
Post reply on HN