Commit c060a97
Cdn cache improvements 3 (#2860)
* Doc: propose model-callback CDN purge as future work
Section 9.3 honestly noted that purging is wired into the controller
update/destroy actions and the bulk recalculation, but not a model callback,
so a future write path that changes a displayed project field could leave the
cached anonymous show page stale until Surrogate-Control max-age expires.
Add Section 11 recording, as a deliberate (not-yet-implemented) proposal, an
after_commit model callback that purges on any project change. Includes the
exact callback, the implementation details that keep it correct (notably
gating on skip_callbacks so the bulk recalc's single purge_all is not turned
into thousands of per-project purges, after_commit vs after_save, enqueue vs
synchronous purge, scope to update/destroy, removing the now-redundant
controller purges, and purge-on-any-update over a fragile column allowlist),
the pros and cons, the residual cross-model (user_display_name) limitation,
and tests.
Doc-only; no behavior change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
* Make CDN re-purge unconditional on project update/destroy
projects#update previously scheduled the delayed re-purge only inside the
"@project.save succeeded" branch. But update_additional_rights writes the
AdditionalRight table (rendered on the anonymous /permissions page) in its
own transaction, which commits independently of @project.save and is not
rolled back if the save later fails. On a save-fails-after-rights-changed
path, only the early immediate purge fired -- losing the delayed re-purge
that closes the TCP-reorder race, so the CDN could hold obsolete collaborator
data until max-age.
Schedule the delayed re-purge unconditionally on entry to update (after the
request is authorized), alongside the early immediate purge, and drop the now
-redundant post-save delayed purge (keeping the post-save immediate purge for
freshest-data eviction). Extra purges are harmless and the request is already
authorized by that point.
Apply the same immediate+delayed pair to destroy, which previously did only
an immediate purge: a stale re-cache of a deleted project's page is exactly
the case worth the extra re-purge.
Also correct an outdated comment: ActiveJob is backed by solid_queue (a
database queue) in production, so the delayed purge is durable and survives a
restart mid-wait -- it is not "stored in RAM" as the old comment claimed.
Add a regression test (CdnCachingTest): a permissions-only update (changing
only additional_rights, project row unchanged) must enqueue PurgeCdnProjectJob
with the project's record_key. Guards against re-gating the purge on
@project.saved_changes?, which would silently serve stale rights.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
---------
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 441e7f4 commit c060a97
3 files changed
Lines changed: 216 additions & 24 deletions
File tree
- app/controllers
- docs
- test/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
693 | | - | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
694 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
695 | 721 | | |
696 | 722 | | |
697 | 723 | | |
| |||
744 | 770 | | |
745 | 771 | | |
746 | 772 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
770 | 778 | | |
771 | 779 | | |
772 | 780 | | |
| |||
811 | 819 | | |
812 | 820 | | |
813 | 821 | | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
814 | 828 | | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
815 | 832 | | |
816 | 833 | | |
817 | 834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
993 | 993 | | |
994 | 994 | | |
995 | 995 | | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
996 | 1008 | | |
997 | 1009 | | |
998 | 1010 | | |
| |||
1251 | 1263 | | |
1252 | 1264 | | |
1253 | 1265 | | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
161 | 184 | | |
162 | 185 | | |
163 | 186 | | |
| |||
0 commit comments