Web Acceleration
The features in the Web Acceleration section help you improve your website's loading speed. Besides a better user experience, this can also improve your website's SEO.
CSS and JavaScript Optimization
When you enable this option, the Arvancloud CDN automatically minifies your website's CSS and JS files, removing whitespace and comments to keep their size to a minimum. This significantly improves the loading speed of these files.
CSS and JavaScript optimization can be enabled separately for each of these two file types.
To manage this feature via API, you can use the following sample request:
curl --location --request PATCH 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/acceleration' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'Content-Type: text/plain' \
--data '{"status":"on","extensions":["css"]}'
In this request, the
statuskey acceptsonandoff, and theextensionskey acceptscssandjs.
Image Compression
When you enable this feature for any of the PNG, JPG, and GIF image types, those files are automatically converted to WebP and, because of their smaller size, load more efficiently.
Note that content must be cached on the CDN edge servers before acceleration settings apply; in other words, only cached content is optimized.
To manage this feature via API, you can use the following sample request:
curl --location --request PATCH 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/acceleration' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'Content-Type: text/plain' \
--data '{"status":"on","extensions":["type"]}'
In this request, the
statuskey acceptsonandoff, and theextensionskey accepts three values:jpeg,png, andgif.
Image Resize
Sometimes you need several versions of the same image in different sizes for different screens. Converting images and storing all these versions costs website owners a lot of processing power and storage space, so a solution to this challenge can be very useful for websites.
With the Image Resize feature of the Arvancloud CDN, you only keep the original version of an image on your servers and can get any size of that image in the browser or in your applications with a single request to the CDN.
This feature works on images in JPG, PNG, and WebP formats; if the input image has a different format, it will not be resized. For GIF files, only the first frame is resized, and it is saved as a non-animated image.
Image Resize has a limit of 4 MB in file size and 5000px by 5000px in dimensions. Images larger than this remain unchanged. If the uploaded file is compressed (for example, in GZip format), the resize is applied to the uncompressed image.
This feature can be defined for the whole domain so it applies to every image loaded on the domain. You can also define Image Resize in Page Rules so images are resized only for specific page rules. Note that if the setting is enabled for a specific page rule and for the whole domain at the same time, the page rule setting takes priority for Image Resize.
Request Structure
Image Resize can be used both to shrink and to enlarge images. The desired dimensions are received as width and height in the query string. The following is a sample Image Resize request:
example.com/path/to/image.jpg?width=x&height=y
In this request, the original file address is https://example.com/path/to/image.jpg, and the desired dimensions are specified with width and height in the query string.
For example, if you need an image in new dimensions, such as 400x250 pixels, add these dimensions to the end of the original file's URL:
example.com/path/to/image.jpg?width=400&height=250
The CDN then returns the image resized to 400x250 pixels. Resized images are cached on the CDN edge servers.
How to Enable Image Resize
With this feature, there is no need to manually change images every time you upload them; with a simple setting, your website's images are resized and adjusted in quality so they are delivered to your audience in the most optimized way. To enable Image Resize on the Arvancloud CDN, simply turn it on in the CDN panel.
Note that this feature is only available on Professional and Enterprise plans.
You can also manage this feature via API:
curl --location --request PATCH 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/image-resize' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data '{"status":"on"}'
In this request, the
statuskey acceptsonandoff.