how to clear or replace a cached image

后端 未结 20 1574
囚心锁ツ
囚心锁ツ 2020-11-29 02:04

I know there are many ways to prevent image caching (such as via META tags), as well as a few nice tricks to ensure that the current version of an image is shown with every

20条回答
  •  抹茶落季
    2020-11-29 02:23

    When changing the image filename is not an option then use a server side session variable and a javascript window.location.reload() function. As follows:

    After Upload Complete:

    Session("reload") = "yes"
    

    On page_load:

    If Session("reload") = "yes" Then
        Session("reload") = Nothing
        ClientScript.RegisterStartupScript(Me.GetType), "ReloadImages", "window.location.reload();", True)
    End If
    

    This allows the client browser to refresh only once because the session variable is reset after one occurance.

    Hope this helps.

提交回复
热议问题