How to make the browser cache an image

Discussion in 'HTML' started by Thomas Mlynarczyk, Jun 30, 2004.

  1. Hi,

    There's a thread here dealing with the opposite problem, and I know I cannot
    force any browser to do anything, but I'd like to know which is the most
    promising way to tell a browser to cache an image.

    Background: There is a number of images which are used on every single page
    of a website (stuff like logo and background image) and I don't want the
    browser to reload them every time from the server (or even "ask" if they're
    still "fresh"). From what I've read so far, this seems to be a .htaccess
    job, but what exactly must I put in there? Or are there other possibilities?

    Thanks in advance,
    Thomas
     
    Thomas Mlynarczyk, Jun 30, 2004
    #1
    1. Advertising

  2. Thomas Mlynarczyk

    Steve Pugh Guest

    "Thomas Mlynarczyk" <> wrote:

    >There's a thread here dealing with the opposite problem, and I know I cannot
    >force any browser to do anything, but I'd like to know which is the most
    >promising way to tell a browser to cache an image.


    They usually are cached, do you have any evidence that yours are not
    being cached? What's the URL of a sample page?

    As ever the best place to start reading on cache issues is
    http://www.mnot.net/cache_docs/

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Jun 30, 2004
    #2
    1. Advertising

  3. Also sprach Steve Pugh:

    >> which is the most promising way to tell a browser to cache an image.

    >
    > They usually are cached, do you have any evidence that yours are not
    > being cached? What's the URL of a sample page?


    Still under development. I just wanted to know what I can do to maximize the
    chance that my images will be cached and thus minimize loading time.

    > As ever the best place to start reading on cache issues is
    > http://www.mnot.net/cache_docs/


    Ah, yes, this one is very instructive indeed. Thanks for the link. As far as
    I've seen, in my current configuration, no "Expires" or "Cache-Control"
    headers are sent. I assume setting them to appropriate values would help
    considerably - or at least that is what the article above suggests. Right?

    Thomas
     
    Thomas Mlynarczyk, Jul 1, 2004
    #3
  4. Thomas Mlynarczyk

    rf Guest

    "Thomas Mlynarczyk" <> wrote in message
    news:cbv75v$ecl$06$-online.com...
    > Hi,
    >
    > There's a thread here dealing with the opposite problem, and I know I

    cannot
    > force any browser to do anything, but I'd like to know which is the most
    > promising way to tell a browser to cache an image.
    >
    > Background: There is a number of images which are used on every single

    page
    > of a website (stuff like logo and background image) and I don't want the
    > browser to reload them every time from the server (or even "ask" if

    they're
    > still "fresh"). From what I've read so far, this seems to be a .htaccess
    > job, but what exactly must I put in there? Or are there other

    possibilities?

    Why should you worry. The internet works just fine by itself(*). Don't try
    to change it but rather spend your time on making your page content better
    :)

    (*) Many people have spent a *LOT* of time and money sorting out the caching
    and refreshing algorithms. These people have a vested interest in the
    matter, being the *large* bandwith providers - the people who own the
    gigabit pipes from counry to country, and the *large* users of their
    services, the top level suppliers of that bandwidth. Don't try to
    second-guess them.

    Bottom line: leave the cache alone.

    --
    Cheers
    Richard.
     
    rf, Jul 1, 2004
    #4
  5. Thomas Mlynarczyk

    Steve Pugh Guest

    "Thomas Mlynarczyk" <> wrote:
    >Also sprach Steve Pugh:
    >
    >>> which is the most promising way to tell a browser to cache an image.

    >>
    >> They usually are cached, do you have any evidence that yours are not
    >> being cached? What's the URL of a sample page?

    >
    >Still under development. I just wanted to know what I can do to maximize the
    >chance that my images will be cached and thus minimize loading time.


    As rf says you almost certainly don't need to do anything as caching
    tends to take care of itself under normal circumstances.

    >> As ever the best place to start reading on cache issues is
    >> http://www.mnot.net/cache_docs/

    >
    >Ah, yes, this one is very instructive indeed. Thanks for the link. As far as
    >I've seen, in my current configuration, no "Expires" or "Cache-Control"
    >headers are sent. I assume setting them to appropriate values would help
    >considerably - or at least that is what the article above suggests. Right?


    Are your images likely to change frequently? Are you images being
    dynamically generated? If your images are static then you really don't
    need to provide any additional information. The most important thing
    to check is that your server is sending an accurate last modifed date
    in the headers for the image (and it almost certainly is). If it's
    doing that then the cache system will work just fine.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Jul 1, 2004
    #5
  6. Thomas Mlynarczyk

    rf Guest

    Steve Pugh wrote:

    > Are your images likely to change frequently? Are you images being
    > dynamically generated? If your images are static then you really don't
    > need to provide any additional information. The most important thing
    > to check is that your server is sending an accurate last modifed date
    > in the headers for the image (and it almost certainly is).


    It *most* certainly is if said server is owned by a hosting company. They
    also have a vested interest, they do *not* want to waste bandwith when they
    can rely on the caches out there to serve the content without a hit on their
    servers.

    --
    Cheers
    Richard.
     
    rf, Jul 1, 2004
    #6
  7. Also sprach Steve Pugh:

    > Are your images likely to change frequently?


    No. They are design elements used on every page.

    > Are you images being dynamically generated?


    No.

    > If your images are static then you really don't
    > need to provide any additional information. The most important thing
    > to check is that your server is sending an accurate last modifed date
    > in the headers for the image (and it almost certainly is). If it's
    > doing that then the cache system will work just fine.


    With Mozilla I can have a look at the header info for HTML files - but how
    can I see those for images?
     
    Thomas Mlynarczyk, Jul 2, 2004
    #7
  8. Also sprach rf:

    [Caching of images to minimize loading time]

    > Why should you worry. The internet works just fine by itself(*).
    > Don't try to change it but rather spend your time on making your page
    > content better :)


    > Bottom line: leave the cache alone.


    Hm. Having tested my pages online by now (using ADSL), I must admit that my
    browsers indeed seem to handle the caching properly. Even better than I had
    thought. Mozilla does not even show a flicker - wow! Still, with a 56K
    modem, the initial loading may take a few seconds (7 pictures, about 12KB
    together - plus one stylesheet of about 5KB [I guess it can be optimized a
    bit more] plus the actual HTML document).

    So I guess I better follow your advice and cancel that cache thing from my
    chores list.

    Thanks to all of you!

    Thomas
     
    Thomas Mlynarczyk, Jul 2, 2004
    #8
  9. Thomas Mlynarczyk

    rf Guest

    "Thomas Mlynarczyk" <> wrote in message
    news:cc3658$p17$01$-online.com...
    > Also sprach Steve Pugh:
    >
    > > Are your images likely to change frequently?

    >
    > No. They are design elements used on every page.
    >
    > > Are you images being dynamically generated?

    >
    > No.
    >
    > > If your images are static then you really don't
    > > need to provide any additional information. The most important thing
    > > to check is that your server is sending an accurate last modifed date
    > > in the headers for the image (and it almost certainly is). If it's
    > > doing that then the cache system will work just fine.

    >
    > With Mozilla I can have a look at the header info for HTML files - but how
    > can I see those for images?


    Point the browser at the image?

    --
    Cheers
    Richard.
     
    rf, Jul 2, 2004
    #9
  10. Also sprach rf:

    >> With Mozilla I can have a look at the header info for HTML files -
    >> but how can I see those for images?

    >
    > Point the browser at the image?


    Of course. Stupid me. Thanks.
     
    Thomas Mlynarczyk, Jul 2, 2004
    #10
    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. Replies:
    2
    Views:
    495
  2. Ronh

    Forcing a browser to cache an image

    Ronh, Feb 1, 2012, in forum: HTML and CSS
    Replies:
    0
    Views:
    592
  3. Jeff Blume

    image reloading and browser cache settings

    Jeff Blume, Aug 6, 2004, in forum: Javascript
    Replies:
    0
    Views:
    140
    Jeff Blume
    Aug 6, 2004
  4. Jake Barnes
    Replies:
    7
    Views:
    226
    Evertjan.
    Dec 8, 2005
  5. Edward Diener
    Replies:
    11
    Views:
    466
    Bart Van der Donck
    Oct 26, 2007
Loading...

Share This Page