16.9.8.3 Using Pre-Authenticated Requests

Use cached PAR URLs to let OCI serve private bucket images directly when possible.

You could optimize app image asset serving using PAR URLs your application creates. As shown below, your app could use a local table to store PAR URLs and expiration dates for image files like x.jpg, y.jpg, and z.jpg files. It could use these PAR URLs directly if they are still valid, or alternatively create a inline image serving page that encapsulates working with the PAR URL for a requested file:
  • If the file's PAR URL in the cache table is still valid, use it
  • If not, create a new PAR URL for the file requested, and save it in the cache table
  • Redirect the browser to the PAR URL.

An automation could run periodically to clean up the expired entries in the cache table. Using an image serving strategy involving PAR URLs, you can defer most or all of the image servring to the object bucket in OCI. The diagram shows how a local table could store the PAR_URL and EXPIRES_AT time for different file OBJECT_NAME entries. Your APEX app could use the cached PAR URLs to delegate image downloading directly to the OCI object bucket.

Figure 16-99 Strategy to Use PAR URLs to Serve Object Bucket Images Directly