Typescript: Why `window.location.reload(true)` is deprecated?

Created on 7 Dec 2018  路  9Comments  路  Source: microsoft/TypeScript

It seems in 3.2.1 deprecated is added to window.location.reload(boolean) in lib.dom.d.ts. I couldn't find anything related in the What's new doc or the release note.

Could I please know why it is deprecated and what is the alternative way to do it?

    /** @deprecated */
    reload(forcedReload: boolean): void;
Question

Most helpful comment

Thanks for replying. That will explain it. Though in browser context, forcedReload flag seems to be pretty irreplaceable. I'm not sure if @deprecated suits it. Now my solution is to simply disable tslint for this usage. I hope there's a better workaround.

All 9 comments

Only the forcedReload flag overload is deprecated. I can't speak as to why, however that info is pulled from the webIDL. If I had to guess, it's because the parameter isn't in the actual spec.

Thanks for replying. That will explain it. Though in browser context, forcedReload flag seems to be pretty irreplaceable. I'm not sure if @deprecated suits it. Now my solution is to simply disable tslint for this usage. I hope there's a better workaround.

This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.

Can anyone tell me another way to get the same result as using the forcedReload parameter here? I want to force the cache to be ignored when a new version of my application is discovered by a polling function and to let the user click a button that will reload the app with the new version. using the forcedReload parameter seems like the best solution, but I'm not sure why it would be deprecated.

from the spec:

User agents may allow the user to explicitly override any caches when reloading. If browsing context's active document's reload override flag is set, then the user agent may instead perform an overridden reload rather than the navigation described in this paragraph (with the browsing context being reloaded as the source browsing context).

to me it appears that it refers to "forceGet" flag of the method. or did i understand badly?

to me it appears that it refers to "forceGet" flag of the method. or did i understand badly?

I'm not sure I understand what you're trying to explain. And it doesn't help me find another solution if forceReload or forceGet as you say is deprecated. @hktr92, can you give me an example?

@jkon

in this spec, the forceGet parameter is loud and clear.

but in this "latest" spec, there's no mention of it at all, not even deprecation one, but there's a subtle reference that the parameter might be present:

User agents may allow the user to explicitly override any caches when reloading.

Why does there seem to be a vendetta from nearly every web technology organization against any way to invalidate cache reliably?

I created a small package in order to have a solution to clean the cache and reload the page if necessary 馃槄 : https://www.npmjs.com/package/clear-cache

Was this page helpful?
0 / 5 - 0 ratings