Use Oracle's CDN for APEX Product Static Files

Search for a command to run...

Hi John, We have Nginx as reverse proxy and we have configured a cache for static files, where it is supposed to be cached by the browser for a long period:
location /i/ {
expires 300d;
rewrite ^/i(/.*)$ $1 break;
root /u01/software/apex/images;
}
The users of the Apex apps are located in several countries in different continents.
Do you think if we activate CDN, we should remove this? Or it will be complementary?
Thanks for your great posts! Jose.
Hi John, Great post. Thank you for sharing.
I can see in APEX 22.1.1 that there are now 2 different paths.
One for APEX Files and one for APP Files.

This simplify the use of CDN for custom files JS/CSS/Etc... We don't need to specify the full path URLs everywhere, we can keep using #APP_FILES#
(I haven't tested yet)
Great one John
Oracle APEX ideas and insights that you can read in four minutes or less.
Introduction When using single sign-on type authentication schemes like Social Sign-In, you need to define a Post-Logout URL in APEX so that the Authentication provider redirects your APEX App to a public page after it completes the logout. When you ...
Introduction One of the marquee features of APEX 26.1 was AI Interactive Reports. When I started testing this new feature, I was interested to see what was going on behind the scenes. In this post, I

Introduction One of the marquee features of APEX 26.1 is APEX AI Agents. APEX AI Agents allow you to use an LLM and your own PL/SQL and JS tools to perform actions on your data instead of just chattin

Introduction In my previous post, I looked at logging APEX AI Agent requests and responses with Request and Response handlers. Logging is the first step because it shows you what is actually moving th

Introduction Logging is one of the first things you need when building serious AI Agents. Without it, debugging quickly becomes guesswork. You can see the final answer, but not always why the model ch

Context management patterns from building agents in Oracle APEX

Take a load off your ORDS server and utilize Oracle's high-speed CDN to serve the APEX product static files for your instance. This has the dual effect of improving page load times and reducing the load on your ORDS server.
Using the Oracle CDN means you do not have to host Oracle APEX Static files on your ORDS Server. This makes APEX upgrades much faster.
Shared Components > User Interface Attributes > General > Static File Prefix

Note: When you set the CDN URL at the Application level, APEX will also look for 'Static Application Files' under this URL. In the example from the above screenshot, the substitution string #APP_FILES# will get changed to https://static.oracle.com/cdn/apex/21.2.4/. If you want to reference custom JS, CSS, or Image files, you cannot store them under 'Static Application Files'. You will need to host custom static files in object storage, a file server, or your CDN and provide references to the complete URL for each file. In the below screenshot, the first reference will not work, and the second will work:

To configure APEX to use the CDN URL for your entire APEX instance, run the following script from a schema that has the APEX_ADMINISTRATOR_ROLE database role.
begin
apex_instance_admin.set_parameter(
p_parameter => 'IMAGE_PREFIX',
p_value => 'https://static.oracle.com/cdn/apex/22.1.0/');
commit;
end;
Use the following to verify:
SELECT apex_instance_admin.get_parameter('IMAGE_PREFIX') FROM dual;
Just in case, here is the code to set static files back:
-- On-Premise Instance.
begin
apex_instance_admin.set_parameter
(p_parameter => 'IMAGE_PREFIX',
p_value => '/i/' );
commit;
end;
-- Autonomous example for APEX 22.1
-- Note: The value can change after Oracle applies patch sets 22.1.0, 22.1.1, etc.
begin
apex_instance_admin.set_parameter
(p_parameter => 'IMAGE_PREFIX',
p_value => '/i/22.1.1/' );
commit;
end;
Note: When you set the CDN URL at the Instance level, APEX will not look for 'Static Application Files' under this URL. This means you can add custom JS, CSS, or Image files in 'Static Application Files' as usual.
In the below screenshot, both references will work:

As you can imagine, the CDN URL changes for each version of APEX and sometimes for each patch set bundle. You can get the correct URL for your version and patch set from the 'Known Issues' section of the APEX Download page for your version.
Example for APEX 21.2

I created a blank, public APEX page with no components on it. The page was developed on an OCI Autonomous Free Tier Instance. I then disabled the browser cache using Chrome Developer tools (see screenshot below). Disabling the cache ensured that all static files were fetched from the server for every page refresh.
I refreshed the page 15 times using the Oracle APEX CDN and 15 times without the CDN. A total of 15 static files were fetched for each page load. I averaged the value of the 'Finish' value in Chrome Developer tools (see screenshot above).
The page loaded 11% faster on average using the CDN.