We have a setup where we have a Contact Us page that submits a form using the plugin from P&T. We will have quite some load on the site, so want to keep all of the GET responses in a CDN cache, CloudFront.

We have an issue where the CSRF token is of course cached in the page and so when the form is submitted by AJAX the token is invalid.

How do we ensure CSRF protection for the form and still have CDN caching enabled for the page?


I don't think you can cache that, since the tag is run server-side and rendered with template output, and will be unique on every page load. If you have content that's unique on every page load, you'd have to either ignore that page from CDN caching, or dynamically load in the unique content after page load via an AJAX call to a page that is ignored from CDN caching.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.