Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 461641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:59:41+00:00 2026-05-12T22:59:41+00:00

Esteemed Overflow-ers of the Stack, So I’ve recently been trying to fully wrap my

  • 0

Esteemed Overflow-ers of the Stack,

So I’ve recently been trying to fully wrap my head around HTTP resource caching. Notably, right now I’m looking at simply the caching of a single, sprited image which is used for rendering icons / small images through out the page. Here’s an explanation of the odd behavior I’m seeing:

So, on the given page I have only a single image: icons.sprite.gif. There are four elements which use the sprite to display various icons on the page. In my Apache config, I have mod_expires installed and the following cache-control directives:

ExpiresActive On
ExpiresDefault "access plus 300 seconds"

ExpiresByType text/html "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 day"

Now, here’s the weirdness. In Safari, when I load the page, the net-inspector reveals only a single request for the sprite. This is perfect, working as expected. On the other hand, with Internet Explorer and Firefox, Fidder / Firebug reveals four successful requests for the sprited image = what!? Subsequent requests result in a single cache hit, but that first load contains four concurrent requests. This seems like a pretty big wtf, as it seems to circumvent the whole point of spriting, which is to the reduce the sheer number of resource requests in a given page-load cycle.

What may be happening:

The page is loading fast enough that by the time the second element is rendered to the document which uses the sprited background image, the first request for the sprite hasn’t finished yet. Accordingly, given the resource isn’t yet cached, as later elements are rendered, they result in a new request for the resource, even though its already being loaded. Safari handles and prevents this somehow (I know that Safari’s caching practices are somewhat different than other browsers).

So — I’m looking for some confirmation / input here. Is this “working as expected” for these browsers — furthermore, does it negate the performance gains associated with spriting (which does introduce css-maintenance complexities)? Alternatively, is there something wrong I’m doing?

I appreciate your thoughts / suggestions.

Cheers,

Skone

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:59:42+00:00Added an answer on May 12, 2026 at 10:59 pm

    So, after extensive munging I figured out how to fix the problem.

    Let say, for instance, that I create a sprite and use css as follows:

    .icon { 
       background: transparent url(/media/common/images/sprite.gif) scroll no-repeat 0 -33px;
    }
    
    .logo {
       background: transparent url(/media/common/images/sprite.gif) scroll no-repeat 0 -10px;
    }
    

    In firefox, this will cause two requests for that image, as opposed to a single request for the image. The fix, accordingly, is to consolidate the css-rules as such:

    .sprited {
      background: transparent url(/media/common/images/sprite.gif) scroll no-repeat 0 0;
    }
    
    .icon { 
       background-position: 0 -33px;
    }
    
    .logo {
       background-position: 0 -10px;
    }
    

    I realize this in itself is more appropriate, as it avoids duplication of the background property among sprited elements.

    Anyway, hope this proves useful for another spriter to be!

    Edit: After a bit of additional testing, this in fact only happens in Mozilla Firefox (platform independent). Safari and IE interpret multiple references to the same image and make a single request, while Firefox appears to make a unique request for each image linked to via CSS.

    I realize its probably not specificly understood as a bug, but in an era where browsers are competing for being labeled the fastest — seems like a potential improvement for Firefox!

    What do you guys think, should I submit this to Mozilla as a bug?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Gentlemen and esteemed ladies. I posted this question in the COM forum at Code
I'm haiving an interesting discussion with an esteemed colleague and would like some additional
Might the esteemed os.system of Python fame throw an exception? If so, which ones?
To the esteemed readers. I'm reasonably new in javascript and I have come across
i am using php,mysql,jquery. When a user clicks on save i go to back
I use javascript to detect long press( a touchstart event then rare touchmove events
This is the situation: A user filters a database by selecting keywords from a
I hate to ask the classic question of business logic in database vs code
Problem: By Rosa Golijan <br/><br/>The next time someone interrupts you to proclaim that retweet
Alrighty, I don't know how I did this, probably the AS3 gods became angry

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.