Commit 7ccc3f0
perf(storage-s3): avoid getObject call if ETag matches (#15295)
### What?
Avoid unnecessary getObject call to S3 when the ETag matches.
### Why?
Range support introduced an early headObject call, which already returns
ETag and metadata; we can use that to short‑circuit with 304 and save a
fetch.
### How?
By using response headers from headObject and check ETag matching before
invoking getObject.
Added a test case for verifying 200 status when If-None-Match does not
match, and 304 status with empty body when If-None-Match is included and
matching.
---------
Co-authored-by: Paul Popus <paul@payloadcms.com>1 parent 43f0d20 commit 7ccc3f0
2 files changed
Lines changed: 50 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 141 | | |
155 | 142 | | |
156 | 143 | | |
157 | 144 | | |
158 | 145 | | |
159 | 146 | | |
160 | 147 | | |
161 | | - | |
162 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
163 | 152 | | |
164 | 153 | | |
165 | | - | |
| 154 | + | |
166 | 155 | | |
167 | 156 | | |
168 | 157 | | |
169 | 158 | | |
170 | | - | |
| 159 | + | |
171 | 160 | | |
172 | 161 | | |
173 | 162 | | |
| |||
184 | 173 | | |
185 | 174 | | |
186 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
138 | 168 | | |
139 | 169 | | |
140 | 170 | | |
| |||
0 commit comments