need to clear cache programmatically using javascript - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

need to clear cache programmatically using javascript

DorkboyDorkboy Posts: 4Member
I need to be able to clear the cache using javascript, any ideas? Kinda new to javascript

Comments

  • lillulillu Posts: 308Member
    Hi,

    I don't think you can do it using client-side javascript.
    You cannot control the user's history as this would raise security issues.
    You cannot even detect the user's preferences on caching (always or never) or set it so that javascript is enabled.

    What you can do is to clear the history of the pages visited on your site only.
    When a document is replaced, it is also removed from the history object, but then the user could type the address again. The back button becomes disabled but it will only affect your site.

    The following script clears the history of your pages on your site: (basically helpful when people share the same browser and you want them to enter your site with a clear history. when they are eg. doing an online quiz / registration or something.


    history.back(yourURL');


    or


    location.replace('yourURL');


    I think - providing you are working with a webserver - you should delve into server-side javascript or ASP to achieve what you want.

    HTH,

    Lillu

    : I need to be able to clear the cache using javascript, any ideas? Kinda new to javascript
    :

Sign In or Register to comment.