I have a template with dozens of static images in it. Is there any way to combine all the GET requests for these images into one request? I am currently using django_compressor for css/js, but have no clue how to do it for images.
Asked
Active
Viewed 56 times
0
-
What exactly you need? You want to get all the static images in a single response in an HTML template page? – Astik Anand Apr 03 '18 at 08:53
-
@AstikAnand Yes – Garvit Jain Apr 03 '18 at 08:58
-
1No. Regular HTTP requests don't work like that. For every resource, browsers make a new HTTP request. But you can maybe serve all the images in one response by using a boundary of some sort to separate the images and then use JS to parse them. Not worth it. But I think HTTP/2.0 solves this by multiplexing a TCP connection. See this: [What does multiplexing mean in HTTP/2](https://stackoverflow.com/questions/36517829/what-does-multiplexing-mean-in-http-2). – xyres Apr 03 '18 at 09:01
-
Every image is a resource and they are accessed using unique `uri` and hence separate request. – Astik Anand Apr 03 '18 at 09:02
-
I see. Thanks for your replies – Garvit Jain Apr 03 '18 at 09:05
1 Answers
0
If all the images are static, as in not coming from the users or the database, but just a set of images you have on the server permanently — combine them into one sprite and use only one sprite image as a background.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Images/Implementing_image_sprites_in_CSS

Andrey Shipilov
- 1,986
- 12
- 14