2

I have a website that I am making. It uses roughly 255 img tags on one page (don't worry, I know what I am doing). Most of these images are from just a few image files.

Basically, that means that most of the images that are shown on the webpage come from just a few image files, so there aren't too many requests made from the browser. That means that there is a lot of copied and pasted code.

These image files are saved on a server, and I don't want to use too much bandwidth in the process of making my website.

So will this webpage completely eat my bandwidth with all the 255 repeated img tags on the page, but with only 8 or nine real image files?

1 Answer 1

3

By default, once a image is loaded it will be cached by the browser. Every additional request for this (exact) image url will be delivered out of the browser cache.

Example: 250 Image tags with just 10 unique image urls. This will only waste the traffic of the size of these 10 images.

You can check that easily by hitting the developer tools of your browser (F12) -> network traffic.

2
  • What conditions would cause behavior other than this default? Jul 28, 2020 at 15:22
  • A very simple and effective way to change the default caching behavior is to "modify" the ETags by using a simple .htaccess file.
    – Marius
    Jul 28, 2020 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.