Image cache problem

Discussion in 'ASP .Net' started by Bei, Oct 14, 2003.

  1. Bei

    Bei Guest

    I have a page which has to change 1 image inside periodically. However, I
    don't have to modify the page to change. I just replace the old image file
    with a new one with the same name.

    Then there is a problem of that (images with same name). Everytime there is
    a new image, the page still show the old image. Even refreshing the page
    doesn't refresh that image. It's because the image name is the same and
    browser just load it from the cache even I refresh. So I have to delete
    "Temporary Internet Files" to view that image.

    Is there a line of code that total disable caching? I have tried:
    Response.AddHeader("Pragma", "No-Cache")
    But that doesn't work for my case.

    Thanks
    Victor
    Bei, Oct 14, 2003
    #1
    1. Advertising

  2. you can have a special page to dispense your images, such as MyImage.aspx
    then when you reference the image you can change the querystring slightly,
    such as
    <image url='MyImage.aspx?Dummy=1'>
    <image url='MyImage.aspx?Dummy=2'>
    etc.

    This way the browser will see it as a new image each time and won't pull it
    from the cache.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com



    "Bei" <> wrote in message
    news:...
    > I have a page which has to change 1 image inside periodically. However, I
    > don't have to modify the page to change. I just replace the old image file
    > with a new one with the same name.
    >
    > Then there is a problem of that (images with same name). Everytime there

    is
    > a new image, the page still show the old image. Even refreshing the page
    > doesn't refresh that image. It's because the image name is the same and
    > browser just load it from the cache even I refresh. So I have to delete
    > "Temporary Internet Files" to view that image.
    >
    > Is there a line of code that total disable caching? I have tried:
    > Response.AddHeader("Pragma", "No-Cache")
    > But that doesn't work for my case.
    >
    > Thanks
    > Victor
    >
    >
    Steve C. Orr [MVP, MCSD], Oct 14, 2003
    #2
    1. Advertising

  3. You can add a changing Query String to the URL for the image. This causes
    the browser to download the image again, as the URL is different. You could,
    for example, append a random number to your Query String, as in:

    <img src="someImage.jpg?1">

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    Big Things are made up of
    Lots of Little Things.

    "Bei" <> wrote in message
    news:...
    > I have a page which has to change 1 image inside periodically. However, I
    > don't have to modify the page to change. I just replace the old image file
    > with a new one with the same name.
    >
    > Then there is a problem of that (images with same name). Everytime there

    is
    > a new image, the page still show the old image. Even refreshing the page
    > doesn't refresh that image. It's because the image name is the same and
    > browser just load it from the cache even I refresh. So I have to delete
    > "Temporary Internet Files" to view that image.
    >
    > Is there a line of code that total disable caching? I have tried:
    > Response.AddHeader("Pragma", "No-Cache")
    > But that doesn't work for my case.
    >
    > Thanks
    > Victor
    >
    >
    Kevin Spencer, Oct 14, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    569
    Jeff Nokes
    Sep 30, 2003
  2. DesignerX

    Page.Cache vs HttpContext.Current.Cache

    DesignerX, Jan 20, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    8,242
    vMike
    Jan 20, 2004
  3. =?Utf-8?B?b25l?=
    Replies:
    1
    Views:
    5,280
    Karl Seguin [MVP]
    Mar 8, 2006
  4. Thomas Brandon

    Treeview image problem (or general cache problem)

    Thomas Brandon, Aug 18, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    174
    Niraj Bhatt
    Sep 15, 2003
  5. Jake Barnes
    Replies:
    7
    Views:
    193
    Evertjan.
    Dec 8, 2005
Loading...

Share This Page