Skip to content

Examples

Refer to the following examples to get started creating your snippet code.

Refer to How it works and Create a snippet in the dashboard for overall guidance.

28 examples

Add HEX timestamp to a request header

Add a custom header to requests sent to the origin server with the current timestamp in hexadecimal format for debugging, tracking, or custom routing purposes.

Auth with headers

Allow or deny a request based on a known pre-shared key in a header. This is not meant to replace the WebCrypto API.

Custom cache

Store, retrieve, and remove assets from cache programmatically. Use this template to optimize performance and implement custom caching strategies.

Debugging logs

Send debugging information in an errored response to a logging service.

Define CORS headers

Adjust Cross-Origin Resource Sharing (CORS) headers and handle preflight requests.

Maintenance page

Serve a custom maintenance page instead of fetching content from the origin server or cache. Ideal for downtime notifications, planned maintenance, or emergency messages.

Set security headers

Set common security headers such as X-XSS-Protection, X-Frame-Options, and X-Content-Type-Options.

Sign requests

Verify a signed request using the HMAC and SHA-256 algorithms or return a 403.