Web Acceleration
You can use the web acceleration feature to improve the loading speed of your website. In this way, you can improve your website’s SEO and user experience.
CSS and JavaScript Optimization
Activating this option will compress your website's CSS and JS files and remove the extra spaces and comments to increase loading speed.
The optimization of CSS and JS files can also be activated separately for each of these file types in page rules.
To manage this feature via API, you can use this sample code:
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 status key accepts on and off, and the extensions key accepts css and js.
Image Compression
You can activate this feature for file types of PNG, JPG, and GIF to automatically convert them to WebP to have them load faster.
Please note that the web acceleration can be done after the content has been cached on CDN edge servers.
To manage this feature via API, you can use this sample code:
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":["png"]}'
In this request the status key accepts on and off, and the extensions key accepts png, jpeg and gif.
Image Resizing
Sometimes, different sizes of an image are needed to make it compatible with different screens. This creates a huge cost in terms of processing power for image conversion and storage space for website owners. The Image Resize feature in the Arvancloud CDN service will keep only the original image on the servers and converts the image to the requested size by the user’s browser or application. This feature is only compatible with an image format of JPG, PNG, and WebP. GIFs will be saved and resized as images only. The feature has a size and dimension limit of 2 MB and 3000px in 3000px. Images beyond these limits will not be resized. If the uploaded file is compressed like GZIp, the resizing process will happen on the original file that is not compressed. This feature can be configured for the whole domain to apply to all uploaded images. You can also define image resize for Page Rules so that the resizing would happen for certain page rules. If the configuration for a specific page rule and the whole domain simultaneously, the priority will be given to the page rules.
Request Structure
Image Resize can make images bigger or smaller. The dimensions will be received in a query string with width and height information like the following:
example.com/path/to/image.jpg?width=x&height=y
In this request, the original file is https://example.com/path/to/image.jpg, and the dimensions with the requested width and height are in the form of a query string. Take the following image as the input.
Now, if this image needs to be resized to 400x250p, the dimensions will be like this in the URL:
example.com/path/to/image.jpg?width=400&height=250
The resized image will look like the following image. The resized images will be cached on the CDN edge servers.
Image Resize Activation
Activating this option will automatically resize your images to become compatible with your users’ browsers and improve user experience. To activate the Image Resize function, it is enough to activate it in the user panel of Arvancloud's CDN service.
Please note that this feature is only accessible to Professional and Enterprise plan users.
To manage this feature via API, you can use this sample code:
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 status key accepts on and off.