# Warmup

API endpoint - `POST /api/2/img/warmup?auth=[API_SECRET]`

## Description

/warmup performs transformations and caches them, so it will speed up the first response time from the real user.

The typical usecase is an application where the user can upload images by themselves, then see them once uploaded. The first render could take some time (1-4 seconds) and using `/warmup` will decrease the response time.

![](https://1476540046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lmt8xTtwpk3g-UlZf5Q%2Fuploads%2Fgit-blob-84c0143d9db428c29d613033141e845afbbe2220%2Fcache-warmup.png?alt=media)

The below example will warm up caches for 2 variants of the image:

* `https://pixboost.com/api/2/img/http://www.midday.coffee/banner.jpeg/resize?size=x100&auth=ABCDEF`
* `https://pixboost.com/api/2/img/http://www.midday.coffee/banner.jpeg/resize?fit=100x100\&auth=ABCDEF`

The URLs of the images to warm up should be exact the same as you use in your front end implementation.

```bash
curl -X POST -H 'Content-Type: application/json' \ 
    'https://pixboost.com/api/2/img/warmup?auth=ABCDEF' \
    -d '{"images: ["https://pixboost.com/api/2/img/http://www.midday.coffee/banner.jpeg/resize?size=x100&auth=ABCDEF","https://pixboost.com/api/2/img/http://www.midday.coffee/banner.jpeg/resize?fit=100x100&auth=ABCDEF"]}'
```

## Parameters

API\_SECRET - [secret key](https://help.pixboost.com/workflows/api-secrets).

## Response

202 - The warmup has been successfully initiated.

## Example

You can find reference example of using cache invalidation workflow with S3 bucket [here](https://github.com/Pixboost/aws-s3-invalidate-cdn). You can replace cache invalidation call with `/warmup` in Lambda.

## Limitations

Maximum number of images to warmup in one call is 20. This is a soft limit and could be increased on request.
