Answers.Body: <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-04T18:29:20.723Z
Answers.LastActivityDate: 2016-04-04T18:29:20.723Z
Answers.UserDisplayName: Ben Wilkins
Body: <p>We have a setup where we have a Contact Us page that submits a form using the plugin from P&amp;T.
  We will have quite some load on the site, so want to keep all of the GET responses in a CDN cache, CloudFront.</p>
  
  <p>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.  </p>
  
  <p>How do we ensure CSRF protection for the form and still have CDN caching enabled for the page?</p>
  
Tags: <cache><csrf>
Title: Using CRSF, AJAX form posts, with a CDN
ThreadText: # Using CRSF, AJAX form posts, with a CDN
  
  (Asked by: username_0 on 2016-04-04)
  
  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?
  
  **Tags:** cache, csrf
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-04. Score: 4
  
  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.
  
  
  ---
  
  