Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The webp file get regenerated each time it was requested. It's a performance issue. Patch coming (initially on #3143491: Private images support).
Comment | File | Size | Author |
---|---|---|---|
#24 | webp-stampede-prevention-22.patch | 7.63 KB | beloglazov91 |
#23 | webp-reroll-3177103-21.patch | 6.83 KB | xrvalencia |
#22 | interdiff_21-22.txt | 681 bytes | kalabro |
#22 | 3177103-webp-stampede-prevention-22.patch | 6.81 KB | kalabro |
#21 | 3177103-webp-stampede-prevention-21.patch | 6.79 KB | dennis_meuwissen |
Issue fork webp-3177103
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
GaëlGComment #4
StryKaizerReroll attached.
Moving this to major.
This brought our high-traffic site down multiple times before detecting the issue.
Comment #5
StryKaizerComment #6
Anas_maw CreditAttribution: Anas_maw at Coders Enterprise Web & Mobile Solutions commentedVery important patch, thank you
Works as expected
Comment #7
mhawwari CreditAttribution: mhawwari at Vardot commented+1 Patch #5 is working for me
Comment #8
Luke.Leberre #5 - we may want to provide a shorter lock acquisition period. According to the docs, it defaults to 30 seconds.
float $timeout: (optional) Lock lifetime in seconds. Defaults to 30.0.
In the event that disk access is slow (mounted filesystem, perhaps?), this could introduce a denial of service vector.
Since the
Retry-After
timing is set to 3 seconds, would it also make sense to reduce the lock acquisition time to 3 seconds as well?Comment #9
leopathu CreditAttribution: leopathu as a volunteer and at Quilltez for Dofinity commentedwe can fix it with simply check with file_exists. Not sure.. why do we need with lock solutions here?
This patch would fix it.
Comment #10
GaëlGThe lock system is copied from web/core/modules/image/src/Controller/ImageStyleDownloadController.php
Comment #11
Luke.Leberre #9: I think the purpose of the lock is to prevent broken images on the frontend while an image is generating. Retry-After wasn't widely supported last I knew. Locking for N seconds is a pretty good workaround in the short term. Otherwise, sites could still have image derivatives generated more than once if a lot of requests hit the page at the same time.
I'd imagine that this could be an issue for high volume traffic sites in particular.
Comment #13
jedihe CreditAttribution: jedihe at Council on Foreign Relations commentedThis is the patch for the current MR. Uploading to have a stable patch for my build.
Comment #14
alexmoreno CreditAttribution: alexmoreno at Acquia commentedcould you have a look at this @jedihe so we can merge ?
https://git.drupalcode.org/project/webp/-/merge_requests/3
Comment #15
alexmoreno CreditAttribution: alexmoreno at Acquia commentedBetter not to rename this method, as it's called as well from FileDownloadController
Needs a docblock.
Comment #16
alexmoreno CreditAttribution: alexmoreno at Acquia commentedComment #18
dk-massive CreditAttribution: dk-massive at Aten Design Group commentedRebased and updated branch with requested edits.
Here is a rerolled patch as well.
Comment #19
dk-massive CreditAttribution: dk-massive at Aten Design Group commentedComment #20
Lukas von BlarerThe MR and the patch don't apply anymore. At least composer complains about it.
Comment #21
dennis_meuwissen CreditAttribution: dennis_meuwissen commentedAttached is an updated patch for the current 1.x-dev version, based on the MR.
Comment #22
kalabroAttached is patch from #21 + #3256454-2: Error "Could not generate image resource from URI" on non-image formats because we need both on our project.
The maintainers most likely will want to review #21.
Comment #23
xrvalencia CreditAttribution: xrvalencia as a volunteer and at Code and Theory commentedRerolling #21 to work with RC1 release.
Comment #24
beloglazov91Rerolling #22 to work with RC1 release.
Comment #25
Peacog CreditAttribution: Peacog as a volunteer commentedThis issue is related to #3435835: Webp derivatives not refreshed when files stored in sub-directory. When that other issue is merged, the code in the new getWebpCopy() method provided by this patch will need to be updated to
$destination = $this->getWebpDestination($uri, '@directory/@filename.webp');
Comment #26
mandclu CreditAttribution: mandclu as a volunteer and at Acquia commentedCan someone provide steps to reproduce? Does this only occur when using Webp with private files?
I tried adding debugging code to the generation method, and it fires when the image is first uploaded, but not when the image is requested again.
Comment #27
Peacog CreditAttribution: Peacog as a volunteer commentedI'm not able to reproduce the problem in #3435835: Webp derivatives not refreshed when files stored in sub-directory any more. Maybe there was a particular combination of versions and patches I was using that caused it. I've struck through my comment above so it doesn't cause confusion