Image cache

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis Allen

    #1

    Image cache

    Hi. I have a piece of client-side code that searches the current page's
    links. If it determines a link < 60 days ago, it uses
    document.links[0].innerHTML += '&nbsp;<img src="'+_img.src +'">', where
    _img = new Image() ; _img.src = "new.gif".

    Problem. If there are 30 links on my page, it seems the image "new.gif"
    has to be downloaded 30 times. If true, why? I wonder if I shouldn't
    first put in a timeout loop and wait for _img.complete to be true. Or
    would that make no difference? ANy advice would be appreciated...D ennis


  • c.anandkumar@gmail.com

    #2
    Re: Image cache

    You could achieve the required functionality by

    - declaring two arrays, one for the image links you have already seen
    and determined to be OLD and another array for those which are
    determined to be NEW (<60 days).

    - For each link that you find in the page, check for its existence in
    the arrays and take an appropriate action.

    - If the link is not found in both of these arrays, you will need to
    determine whether they are new or old by your logic, take the
    appropriate action and then updating the corresponding array.

    This will help u in minimising the no. of downloads.

    Thanks

    Anand

    Comment

    • Dennis Allen

      #3
      Re: Image cache


      <c.anandkumar@g mail.com> wrote in message
      news:1110187377 .154025.203420@ g14g2000cwa.goo glegroups.com.. .[color=blue]
      > You could achieve the required functionality by
      >
      > - declaring two arrays, one for the image links you have already seen
      > and determined to be OLD and another array for those which are
      > determined to be NEW (<60 days).
      >
      > - For each link that you find in the page, check for its existence in
      > the arrays and take an appropriate action.
      >
      > - If the link is not found in both of these arrays, you will need to
      > determine whether they are new or old by your logic, take the
      > appropriate action and then updating the corresponding array.[/color]

      How?? I can determine which links need the little new.gif icon, so how
      do I set them?


      Comment

      Working...