Global Static Files (1)

Some static files used in different applications may be the same, such as the favicon icon and custom HTML files.

By putting these static files in Global Static Files, you can reference them in an application whenever you need them.

First, we upload a favicon icon to the Global Static Files:

This page lists all existing global static files.

Click the Upload File button to upload a new one.

It’s very easy. Upload a favicon icon and write the label name of the static file.

Files come in two types. One is static files similar to the favicon icon, the other is custom HTML code, which can be used for Custom Error Page of the application.

Please note that the size of the uploaded file must not exceed 32 KB to successfully upload it.

Select to upload one favicon icon with the label name openresty.

Click the Save button on the bottom right-hand corner after uploading the icon, and a global static file is now successfully uploaded.

You can see information about the newly added file on the Global Static File page:

Then, create an application to see how to refer this static file:

Newly add a Page Rules and select static file in Content:

Select the favicon icon just uploaded and then Save:

Now, you can reference a global static file in an application.

But the release process is needed to make it work on the edge node. As for details about the release, no further explanation is necessary.

Now, verify as below:

curl -s -v -o favicon -H 'host: test.openresty.com'  http://52.43.45.19/favicon
*   Trying 52.53.251.226:80...
* Connected to 52.53.251.226 (52.53.251.226) port 80 (#0)
> GET /favicon HTTP/1.1
> Host: test.openresty.com
> User-Agent: curl/7.76.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Tue, 14 Nov 2023 11:10:21 GMT
< Content-Type: image/x-icon
< Content-Length: 12552
< Last-Modified: Wed, 23 Mar 2022 10:52:11 GMT
< Connection: keep-alive
< ETag: "623afbdb-3108"
< Server: OpenResty Edge
< Accept-Ranges: bytes
<
{ [5792 bytes data]

Indeed, the favicon icon is in the returned value.

What will happen if we try to delete this global static file?

Return to the Global Static Files page:

Then, delete the uploaded static file:

The above error prompt pops up as the static file being used by the application cannot be deleted.