Based on this post, I took a look at my log and discovered that I have larger blocks of simultaneous requests.
44 Requests in 9 seconds by 1 user.
Although the avatar images have a cache header, each image is queried by the server. A look at the endpoint shows that such a simple request is painfully pulled through the CRM even though the file already exists ready for download. But more on that later.
In the Avatar.php the value t / timestamp is not requested. Therefore, the parameter can (normally) be removed. I have tested this once.
After
Cache works, even when loading additional content no request is sent to the server.
If you're already touching on the subject:
Change from jpeg to webP
Currently, the images are created in jpeg. webP has been supported by all common browsers for a long time. In my tests, the file size is about half as large.
3.88kb jpeg -> 2.20kb webP
Create images on upload, not on fetch
If images are created and saved in the correct sizes when they are uploaded, you can actually handle all the requests outside the CRM.
To be on the safe side, create a unique folder for avatars and then save the images in it with user_id.
/uuid/userId_size.webp
If you do not want to do without the access check, you can also keep the access point and set a 302 header after a successful check. Since the image will load in the cache anyway, a redirection would not be frequent.
In any case, you can save a lot of unnecessary server load if you make a few adjustments here. The quickest and most effective fix would be to remove the timestamp from the request.
Code:
111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936277 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936278 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936275 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936280 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936282 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936284 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936283 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936286 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936287 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936288 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936289 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936290 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936291 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:18:56 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051936293 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942154 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942155 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942153 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942157 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942158 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942159 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942160 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942161 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942162 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942163 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942164 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942166 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942165 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942167 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942168 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:02 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051942170 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944944 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944942 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944943 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944946 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944945 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944947 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944948 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944949 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944951 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944953 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944954 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944956 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944955 HTTP/2.0" 200 456 "https://www.domain.work/" 111.222.333.444 - - [03/Dec/2022:07:19:05 +0000] "GET /?entryPoint=avatar&size=small&id=1&t=1670051944958 HTTP/2.0" 200 456 "https://www.domain.work/"
Although the avatar images have a cache header, each image is queried by the server. A look at the endpoint shows that such a simple request is painfully pulled through the CRM even though the file already exists ready for download. But more on that later.
In the Avatar.php the value t / timestamp is not requested. Therefore, the parameter can (normally) be removed. I have tested this once.
After
Cache works, even when loading additional content no request is sent to the server.
If you're already touching on the subject:
Change from jpeg to webP
Currently, the images are created in jpeg. webP has been supported by all common browsers for a long time. In my tests, the file size is about half as large.
3.88kb jpeg -> 2.20kb webP
Create images on upload, not on fetch
If images are created and saved in the correct sizes when they are uploaded, you can actually handle all the requests outside the CRM.
To be on the safe side, create a unique folder for avatars and then save the images in it with user_id.
/uuid/userId_size.webp
If you do not want to do without the access check, you can also keep the access point and set a 302 header after a successful check. Since the image will load in the cache anyway, a redirection would not be frequent.
In any case, you can save a lot of unnecessary server load if you make a few adjustments here. The quickest and most effective fix would be to remove the timestamp from the request.
Comment