Create an API endpoint for fetching GeoIP data for the requesting browser, implemented 100% at the edge. The response should show your current approximate location, but no requests to any origin servers.
Solution recipes for travel and hospitality
Our recipe library is an always-evolving set of code samples to do just about anything on the Fastly edge cloud. Have a browse or search for a keyword to find the perfect, ready-made solution you can paste into your service or adapt and customize for your own needs. Using Fastly Fiddle, play with any recipe and take advantage of the Fastly edge cloud, all without registering or affecting any existing account.
Add GeoIP data about the client browser as extra headers in any requests from Fastly to your origin.
Detect requests that contain submitted passwords and use a service to determine whether the password has leaked before allowing the request to proceed to origin (data from haveibeenpwned).
Stream responses to the browser while still receiving data from the origin and also saving it to cache. Great for spreading out server-sent-events streams to millions of users from a single source stream.
Collect and aggregate log data submitted from browsers directly into S3 or another log store without having to handle the traffic at your origin.
Send request to different origin servers based on the URL path.
Deal with all potential scenarios for using stale content to satisfy requests when origin is unhealthy or misbehaving.
Map requests to backends based on user ID (a.k.a., "sticky sessions"). Defaults to IP address but you can customize.
Emit logging data to your chosen log endpoint from any VCL stage, not just vcl_log.
Serve binary objects, such as images, directly from edge configuration by encoding them using Base64 encoding.
Use AWS authenticated requests (signature version 2) to protect communication between your Fastly service and AWS.
Represent non-ASCII characters in VCL using unicode escapes.
Useful for comparing capabilities with required permissions.
Use Fastly's support for ESI to combine multiple origin-hosted objects into a single response at the edge.
Bucket users into small grid squares to allow for hyper-local content caching (e.g., "stores near you", "local offers").
Use custom, predefined classnames like large, medium, small, teaser, thumb, or article to control Fastly Image Optimizer and optionally prevent end-user access to native properties like 'width'.
A totally stateless solution to hold back new users for a minimum waiting period to smooth out spikes in traffic.
All code on this page is provided under both the BSD and MIT open source licenses.