SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict revlimiter's Avatar
    Join Date
    Sep 2005
    Location
    British Columbia, Canada
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Caching background Images on page load?

    Every time I click on a navigation button (Home, About, Contact, etc.) it loads refreshes the CSS background images. Is there a good way to cache the backgrounds so that they don't have to keep loading every time?

    Thanks,
    "To make an apple pie from scratch,
    you must first create the universe.
    -Carl Sagan

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,546
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by revlimiter View Post
    Every time I click on a navigation button (Home, About, Contact, etc.) it loads refreshes the CSS background images. Is there a good way to cache the backgrounds so that they don't have to keep loading every time?

    Thanks,
    Hi,

    If you are talking about the first time that you hover over an element such as a nav then the best way is to use sprites so that the over state of the image is loaded along with the normal state and doesn't need to be fetched when you need the hover state. This old example uses this image for the normal and hover states.

    If you have different images for each state then you have to class every item and adjust the background-position to fit each item as required.

    If you are experiencing some other issue then it may be that you have set images not to be cached in your browser settings.


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
  •