Pre-flighted JavaScript requests

PUT request with max age

Summary

JavaScript code can make a cross-origin PUT request. The pre-flight response can include an Access-Control-Max-Age header, causing the browser to cache the response for the specified number of seconds.

Instructions

  1. Press F12 to open browser Developer Tools
  2. Open Network tab and filter by path put-max-age
  3. Ensure Disable cache checkbox is not selected
  4. Hit green button below and observe 1 pre-flight and 1 main request
  5. Refresh page, hit button again, observing 0 pre-flight requests
  6. Wait until cache expires (60 seconds)
  7. Refresh page, hit button again, observing pre-flight request again
View source on GitHub | Created by Tom Gregory