kkuchta/css-only-chat

Idea: Solve single-use button problem using cache busting headers

Closed this issue · 1 comments

By sending the Cache-control: private, max-age=0, no-cache and Expires: Thursday, 1 January 1970 00:00:00 GMT we can force the browser to send requests while reusing the background image (less state tracking).

Interesting... we may not actually need that.

So, the root issue is that if there's a single <div id='A'> and we've got:

#A:active {
  background-image: url('/img/a.jpg');
}

then on the first click, a.jpg gets loaded and on subsequent clicks, it doesn't get loaded again. I kinda assumed that if we put multiple elements with the same background image on the page, we'd only get one request. It looks like that might not be the case.

#A:active {
  background-image: url('/img/a.jpg');
}
#B:active {
  background-image: url('/img/a.jpg');
}

^ given that, even with no interesting cache headers at all, chrome will load img/a.jpg twice, once on each button click. And if we're replacing the whole DOM every button click anyway, you're right: we really only need the image url to include just the single letter being used (and probably the client_id). No more url('/img/helloworld-and-all-previous-messages-a.') XD