fetch
fetch copied to clipboard
Please add support for an indicator as to whether the page was resolved via a temporary redirect or a permanent one
Use case: I have a browser app that stores URLs (bookmarks or whatever). From time to time URLs get redirected, either permanently or temporarily.
It would be helpful to update the stored URLs as and when they are permanently redirected, as
- the original URL may go out of service
- every time I subsequently use the original URL it will result in one or more extra requests to fetch the web page.
I can tell (in general) that the request has been redirected because the responseURL field will not be the same as the URL I used in the open. However, there's currently no way I can determine if that was due to a temporary redirect or a permanent one. And if the redirect is temporary I do not want to update my stored URL because when the redirect goes away, the URL will be wrong.
Therefore a single (read only) field in the request set to which is filled in on a successful request (with true indicating the url was changed due to one or more temporary redirects, and false indicating that no temporary redirects were found while performing the request) would be extremely helpful.
I think it might also improve users experience if those browsers that displayed the target URL in the address bar took notice of this, as taking a bookmark on a URL generated as the result of a temporary redirect would potentially have unhelpful results.
So #601 would solve this, but due to the much more limited scope this might be okay exposing under some circumstances without opt-in header.
The one thing that's not considered in OP is that there might be multiple redirects, some of which are temporary, some of which are permanent. In those cases we'd only be able to say temporary as we don't want to reveal how many redirects there were.
Ah. I did consider that. I forgot to state it explicitly (or explicitly enough). I was working on the basis if there was one or more temporary redirect, that'd mark the whole result as a temporary redirection being in place.
Updated description slightly as per annevk's comment.
I have the exact same use case. For me, it is a podcast aggregator app (actually a browser extension), in which I'd like to update my persisted podcast feed URL in case of a permanent redirect - currently I cannot do that, as I don't know if the redirect is permanent or temporary. I could accept the limitation of not being able to detect a new permanent URL in case there are also temporary redirects in the mix (although, that is still a gap for me).