SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict mr.pita's Avatar
    Join Date
    Aug 2005
    Location
    USA
    Posts
    303
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Force a re-cache

    I have an image site set so that if an image is linked to directly (meaning if the referrer isn't my site) then it redirects to the page that the image is on.

    This works fine for FF and IE, but in Chrome and probably Safari, after the redirect the image doesn't show up because the browser has already cached it as a redirect. Only after a refresh does it show up.

    Any way around this?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2010
    Location
    Sofia, Bulgaria
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use random parameter to the file name on the page.
    For example:
    Code:
    <img src="image.png?123321" />

  3. #3
    SitePoint Addict mr.pita's Avatar
    Join Date
    Aug 2005
    Location
    USA
    Posts
    303
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought about that, but I didn't like the inconsistency of having a different file name each time. As long as it works (does anybody know if browsers don't just ignore the extra stuff at the end?), then I suppose I'll go with it.

    Thanks!

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Mr PITA,

    Once a file is downloaded to a browser (and placed in its cache), there is nothing which you can do to prevent the browser from extracting it from its own cache.

    With HTML (PHP, etc) files which render as a page, it's a simple matter to include expiry data IN THE SCRIPT. With images, that's just not possible.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •