How to programmatically empty browser cache?

前端 未结 11 973
迷失自我
迷失自我 2020-11-22 17:36

I am looking for a way to programmatically empty the browser cache. I am doing this because the application caches confidential data and I\'d like to remove those when you p

11条回答
  •  自闭症患者
    2020-11-22 17:55

    There's no way a browser will let you clear its cache. It would be a huge security issue if that were possible. This could be very easily abused - the minute a browser supports such a "feature" will be the minute I uninstall it from my computer.

    What you can do is to tell it not to cache your page, by sending the appropriate headers or using these meta tags:

    
    
    
    

    You might also want to consider turning off auto-complete on form fields, although I'm afraid there's a standard way to do it (see this question).

    Regardless, I would like to point out that if you are working with sensitive data you should be using SSL. If you aren't using SSL, anyone with access to the network can sniff network traffic and easily see what your user is seeing.

    Using SSL also makes some browsers not use caching unless explicitly told to. See this question.

提交回复
热议问题