Make webforms cacheable again

Created on 11 February 2025, 8 months ago

Problem/Motivation

Core marked any entity form as uncacheable (max-age = 0) in πŸ“Œ Form tokens are now rendered lazily, allow forms to opt in to be cacheable Needs review and this will be fixed in πŸ“Œ Make entity forms cacheable Active .
However, after upgrading to Drupal 11 and seeing the flow on effects on our projects, I think we should manually remove this max-age in WebformSubmissionForm.

If you are using Webform on Drupal 11 with https://www.drupal.org/project/cache_control_override β†’ you will get pages without a max-age set in the Cache-Control header resulting in pages being uncacheable by the CDN (bad).

WebformSubmissionForms are cached in D10.4 and I don't think any of the issues that πŸ“Œ Make entity forms cacheable Active will tackle will really apply to Webforms.

Steps to reproduce

Install Webform on D11
Install cache_control_override
Create a page with a webform on it
Notice Cache-Control headers are set to no-cache

Proposed resolution

Do a unset($form['#cache']['max-age']); after $form = parent::form($form, $form_state); in WebformSubmissionForm::buildForm

πŸ› Bug report
Status

Active

Version

6.3

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @acbramley
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Pipeline finished with Failed
    8 months ago
    Total: 403s
    #420469
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Pipeline finished with Failed
    8 months ago
    Total: 840s
    #420477
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Gonna be a bit trickier than I first expected by the looks of the test failures. It seems like some things perhaps aren't setting the cacheable metadata that they should be on Webform's end and were just coincidentally passing before.

  • Pipeline finished with Failed
    8 months ago
    Total: 747s
    #420503
  • Pipeline finished with Canceled
    8 months ago
    Total: 127s
    #420520
  • Pipeline finished with Success
    8 months ago
    Total: 1360s
    #420521
  • Pipeline finished with Canceled
    8 months ago
    Total: 133s
    #421010
  • Pipeline finished with Failed
    8 months ago
    Total: 467s
    #421012
  • Pipeline finished with Failed
    8 months ago
    Total: 1191s
    #421026
  • Pipeline finished with Failed
    8 months ago
    Total: 1131s
    #421061
  • Pipeline finished with Failed
    8 months ago
    Total: 1131s
    #421219
  • Pipeline finished with Failed
    8 months ago
    Total: 1272s
    #421450
  • Pipeline finished with Success
    8 months ago
    Total: 1926s
    #421508
  • Pipeline finished with Success
    5 months ago
    Total: 313s
    #495916
  • Status changed to Needs work 3 months ago
  • πŸ‡©πŸ‡ͺGermany pminf Nuremburg (Germany), formerly Dresden

    @acbramley Is this a general issue with Webform in Drupal 11 or just in combination with cache_control_override?

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    @pminf unrelated to cache_control_override, it's just webform + D11

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    liam morland β†’ made their first commit to this issue’s fork.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 626s
    #576869
  • Pipeline finished with Success
    about 1 month ago
    #581061
Production build 0.71.5 2024