Applications
Route requests to your origins, cache responses, and run code with the rules of an Application, then turn on Application Accelerator or Image Processor.
Applications is a Platform Resource that processes the requests received by your Workloads, from the data center nearest to your user. An Application can run serverless functions, act as a reverse proxy for your origins, or combine the two. It can also store responses with Cache, unlock four capabilities for the cache and the rules with Application Accelerator, and transform images with Image Processor. Use Applications to run a Function, set the Connector that reaches each origin, add or remove headers, or rewrite requests.
Each Application can use these nested resources and features:
- Cache lets an Application answer a request with a copy of an earlier origin response. For example, your static files stay in the data center nearest to your user.
- Application Accelerator is a good fit when one URL has more than one correct response, such as a personalized page or a
POSTresponse. Cache then keeps a separate copy for each value of a query-string argument, a cookie, the device group, or the method. - Image Processor fits a page that needs one image in several sizes, crops, qualities, or formats, such as WEBP for browsers that accept it. Every variant then comes from one file on your origin, so you store and upload only that file.
- Device Groups lets an Application tell apart the devices that send its requests, so a rule or a cache setting can treat each group differently. It needs Application Accelerator turned on in the Application.
- Rules Engine for Applications is where you write what an Application does with each request it receives. For example, one rule can route
/api/to one origin while a second rule routes every other path to another. - WebSocket Proxy lets an Application carry a WebSocket connection between your users and your origin. Azion turns it on for an account only on request.
- A Function Instance lets an Application run one of your Functions. For example, the same Function can run in more than one Application, each Function Instance with its own arguments.
Request path
Creating an Application routes no request to it: a request reaches an Application only once a Workload’s deployment sets that Application. The Application then reaches an origin only through a rule that sets a Connector. In place of an origin, a rule can run a Function that builds the response with no Connector.
The diagram follows a request that reaches an origin. Solid arrows carry the request, and dotted arrows carry the response. Each label starts with the number of its step below.
- The request reaches a Workload through one of its domains, and the Workload forwards it to the Application. When the Workload’s deployment also sets a Firewall, the Firewall runs its rules first and can refuse the request.
- The Application runs its Request Phase rules in order. When a behavior, the action a rule runs, ends the processing, as Deny (403 Forbidden) does, the Application answers the client, and no later rule runs.
- A rule with Set Cache Policy can apply a cache setting, the set of values that tells Cache how to store and serve a response. Cache then looks for a valid copy of the origin response. If Cache holds one, that copy becomes the response, and the origin receives no request.
- Otherwise, the Connector that a rule with Set Connector sets routes the request to the origin. If several matching rules carry Set Connector, only the last of them runs.
- The Application runs its Response Phase rules on the response, and the response reaches the client.