Rihla catalogue — product data in S3 and CloudFront

A public product catalogue for Rihla Fragrances, on the Cloudflare-hosted static site. The product data is a JSON file and some photos in S3, with no server code to run.

Updated December 2026 · Visit the live site · Operations docs

What it is for

The site needed a way to show what the business sells and in which sizes. The catalogue does that with a photo grid: tabs for Sprays and Rollers and for each brand's collection, with 72 products in 80 sizes across two brands. Each size is marked in or out of stock, and prices are shown publicly.

It is not a shop. There is no cart or checkout, and customers still use the enquiry form to order. The constraint was the same as for the rest of the site: low cost and little to maintain.

How it works

Product data is one file, catalogue.json, plus a WebP photo per product size. Both sit in a private S3 bucket. CloudFront serves them using Origin Access Control, so the bucket is never public and only the distribution can read it. The catalogue page fetches the JSON from a URL held in config.js, which chooses the test or production path by hostname, then builds the grid in the browser.

  1. Browser

    Load the catalogue page

    The static page reads the data URL from config.js and fetches the JSON.

  2. CloudFront

    Serve from cache

    A custom cache policy includes the Origin header in the cache key, so cross-origin responses stay correct.

  3. S3

    Fetch on a cache miss

    The private bucket holds catalogue.json and the photos, readable only through Origin Access Control.

  4. Browser

    Render the grid

    Tabs group products by type and collection, and each size shows its own stock state.

Test and production use separate paths in the same bucket.

Keeping the data up to date

There is no admin interface. Three small routines, all run from the command line, cover the work:

  • Photos. A script converts supplier photos to 600×800 WebP, named after the product and size.
  • New products. merge_catalogue.py adds new products to the live JSON without touching existing stock flags, so adding a batch cannot undo stock changes made since the last upload.
  • Stock. set_stock.py marks sizes in or out of stock by name and size, for quick updates after an event.

Decisions worth explaining

S3 and CloudFront rather than a database

I considered two alternatives. DynamoDB behind a Lambda API would allow queries and a future admin page, but it adds code to write, secure and monitor for a catalogue that is mostly static data. Keeping the JSON in the site repository would be simplest, but every stock change would become a commit and a deploy, and the photos would bloat the repository. S3 behind CloudFront costs almost nothing and has no code to run, and stock changes go live without a deploy.

A private bucket with Origin Access Control

The bucket has no public access. The data is public anyway, but a private bucket means the only way in is through the distribution, so objects cannot be reached by guessing S3 URLs.

Public prices, and the product as the unit

Prices are shown on the page, which keeps the data model simple: each size carries its own price, photo and stock flag. The cost is that the file is readable by anyone, so it cannot hold anything private.

A short cache lifetime

Objects are uploaded with max-age=300, so a stock change shows within about five minutes, and the cache is invalidated when it needs to be sooner.

What broke

CORS worked in curl and failed in browsers

The first version used CloudFront's managed SimpleCORS response headers policy. Requests made with curl returned the right headers, but the browser blocked the fetch. Because the response varies by origin, the cache needs to know about the Origin header, and the managed cache policy ignores it, so a response cached for one origin could be handed to another.

The fix was two changes: CORS rules on the S3 bucket for the live, www and preview origins, and a custom cache policy with Origin in the cache key. A new hostname, such as a local server, now has to be added to the bucket's CORS rules before it can load the data.

Stock changes that did not appear

After I marked a product out of stock, the page kept showing it in stock. Uploads made through the S3 console had lost their Cache-Control header, so CloudFront fell back to its default lifetime and served the old copy for up to 24 hours.

I now upload with the AWS CLI, which sets max-age=300 explicitly, and create an invalidation after an urgent change. The upload commands are written down in the operations docs so the console is not the easy path.

A logo link that covered the whole header

On the site's subpages, including the catalogue page, clicking anywhere in the band beside the logo went to the homepage. The link wrapped an image displayed as a block, so its clickable area stretched across the whole width of the page header. It was a layout bug in the site's own CSS rather than anything in the catalogue. The fix was to size the link to the logo, 200 px wide, and let the image fill it. The layout did not change.

The CORS and cache problems shared a cause: both were CloudFront behaving exactly as configured, with a configuration that was fine for curl and wrong for a browser. The lesson I took is to test cross-origin features from a real page on the real hostname before calling them done.

Known limitations and next steps

Stock is edited by hand. It means running a script and an upload from the command line. There is no admin interface.

Prices and stock are public. Anyone can read the whole file, so it can never hold wholesale costs or customer data.

It is not infrastructure as code. The bucket, distribution and policies were created in the console. Writing them in Terraform is planned, and the operations docs record the settings in the meantime.

Stack

Site
HTML, CSS, JavaScript, Cloudflare Workers static assets
Data
JSON catalogue, WebP images, AWS S3 (private bucket), CloudFront with Origin Access Control
Tooling
Python scripts (standard library), AWS CLI

The rest of the site is covered in Rihla website — static site with a serverless AWS backend.