Moving PHP e-commerce to CloudFront safely

Migrating a PHP e-commerce site to a CloudFront CDN does not require rewriting the application or moving every workload to serverless. CloudFront can become the public entry point, serve cacheable pages and assets from edge locations, and forward requests that need the application to the existing origin. PHP remains responsible for carts, orders, accounts and administration.

For an Australian store, the benefit is tangible. Sydney, Melbourne, Brisbane and Perth shoppers should receive cached content closer to their connections, while the origin can remain in one of AWS’s Australian regions near the core customer base. Test with NBN, mobile and fixed-wireless connections rather than treating a connection to a local datacentre as representative.

Peak trading changes the risk profile. Click Frenzy, Black Friday, Cyber Monday and EOFY sales can send a normal catalogue from a manageable load to a sudden surge of origin requests. A staged migration, with explicit cache rules and a rollback path, is more valuable than squeezing the last few milliseconds from the homepage.

Designing the cache around storefront behaviour

Start by separating traffic into two classes. Anonymous landing pages, category listings, product pages and versioned CSS, JavaScript, images and fonts are candidates for caching when the response is the same for everyone. Carts, logins, checkout, account pages and order status should continue to reach PHP, usually with caching disabled. CloudFront normally caches eligible GET and HEAD requests, so POST traffic such as basket updates is excluded by design.

Managed cache policies are preferable to scattered legacy settings, but verify the application’s Cache-Control and Expires headers. Keep query strings only when they change the resource, and do not let session identifiers appear in cacheable query strings. Treat responses that set a session cookie as private, then test the exact configuration with baskets, discount codes and logged-in accounts.

Use signed URLs or signed cookies for protected downloads, and give static media a separate origin path so its lifetime can be tuned independently. An origin in Sydney or Melbourne keeps application traffic within Australian infrastructure, but edge cache locations do not make privacy compliance automatic. Review the Australian Privacy Principles, contractual obligations and where personal data is processed. CloudFront remains a delivery layer, not a PHP runtime: the origin still needs capacity and healthy database connections. An origin shield can collapse repeated misses onto one upstream tier when traffic is distributed widely.

Preparing the PHP origin for edge traffic

The target topology can stay conventional. Route 53 resolves the hostname, CloudFront handles public TLS and applies cache and WAF policy, and an ALB sends dynamic requests to ECS or EC2 running PHP, which uses RDS. This keeps the migration focused on delivery rather than an application rewrite.

Configure the origin to handle CloudFront requests correctly. Preserve the Host value expected by the load balancer, set up trusted proxy handling in PHP, and use X-Forwarded-For only when it arrives through a known load balancer or CloudFront path. Restrict the load balancer or web server to CloudFront traffic so attackers cannot bypass WAF rules by addressing the origin directly.

For a custom hostname, attach an ACM certificate to the distribution, and use HTTPS between CloudFront and the origin even when the origin sits inside the VPC. If traffic moves through an ALB, ECS or EC2 service, test health checks, redirects, uploaded files and PHP sessions before changing DNS. A successful deployment is not proof that the complete request path works.

Automation should cover more than a successful file transfer. Run deployment and smoke tests against a staging origin, then repeat product, login, discount-code, payment and checkout checks through CloudFront. My Raspberry Pi Runner guide shows how a small GitLab Runner cluster can provide repeatable build capacity; it is useful for rehearsals, not a production home for the storefront.

Securing DNS and measuring the cutover

Use Route 53 or the existing authoritative DNS provider to point the storefront hostname at the distribution. Lower the DNS TTL in advance, keep the old record available during validation, and use health checks or weighted records for a cautious rollout. Managed WAF rules, rate limits and bot controls should protect expensive PHP endpoints before traffic is opened.

Measure the business as well as the infrastructure. Compare cache-hit ratio, origin latency, 5xx rates, checkout completion and revenue per session before and after the move. CloudFront standard and real-time logs, ALB logs and application traces need a shared request identifier. Synthetic checks from Melbourne, Sydney and Brisbane make regional regressions visible before customers report them.

Watch the bill as well as the dashboard. Request charges, data transfer, invalidations, WAF capacity and origin compute all remain. Australian pricing usually needs one AUD display with GST included; if the store exposes other currencies or markets, include only the dimensions required to produce the correct page in the cache key. A fair dinkum speed gain is one that preserves margin.

Rehearsing migration with a practical checklist

Rehearse with a production-shaped catalogue and representative media, not a handful of placeholder products. Warm the cache with common category and product URLs, then apply a traffic profile that models Click Frenzy or a sale email burst. For a cautious release, create a second distribution and use weighted DNS records to send a small cohort through it while the current path remains available for rollback.

Plan cache invalidation for price changes, stock updates and campaign edits. Versioned asset filenames avoid many purges, while short TTLs limit the age of HTML that cannot be versioned. If product copy is managed through Microsoft 365, include that publishing path in the rehearsal. The SharePoint content guidance can help separate content operations from storefront delivery, while the commerce team defines which exported pages may be cached and how stale content gets removed.

During the busiest period, autoscaling, database headroom and an operations contact matter more than a perfect cache ratio. Put the person who can pause the rollout and the person who can restore routing in the same change brief. Test a CloudFront or origin failure under load, document who makes the call, and keep checkout monitoring visible throughout. A practical sequence keeps each change measurable and reversible:

  • Record baseline page speed, origin load, checkout conversion, payment failures and support-contact volume.
  • Label every route as shared-cacheable, private, signed or origin-only, then review those labels with developers.
  • Automate builds, security checks and end-to-end tests before a distribution receives customer traffic.
  • Shift a small DNS-weighted cohort, watch checkout and order data closely, and define the threshold that pauses promotion.
  • Keep rollback DNS, origin capacity and a cache-purge runbook open until the busiest sales period has passed.

Start with a measured migration

Begin with the homepage, static assets and anonymous catalogue pages, then add selected product and category templates after observing real logs. Keep payment processing outside shared caching and use a canary distribution for the first traffic slice. Promote only when checkout success, order totals and support-contact volume remain normal.

Create a one-page migration brief this week: name the cacheable routes, nominate an Australian origin region, set measurable success thresholds and rehearse the rollback. Then launch the first distribution with a measured cohort, document every configuration change and expand traffic only while customer and operational metrics remain stable.

Experience

Information Technology Consulting

Independent Practice

Provides IT consulting services focused on infrastructure planning, cloud migration strategy, and systems architecture. Engagements draw on years of hands-on sysadmin and development experience across Linux, Windows, and hybrid environments.

K9 Search & Rescue Volunteer

Ongoing

Active participant in K9 Search & Rescue operations, combining technical logistics skills with field support for canine search teams.

Karl Katzke's Blog

October 2006 – May 2014

Published a long-running personal technology blog covering cloud vs. in-house infrastructure, F# and Mono on OSX, hardware vendor critiques, RAID card performance analysis, and sysadmin storytelling. Notable posts include "When Sysadmins Ruled the Earth" (May 15, 2014) and "Getting Started with F# and Mono on OSX" (December 22, 2012).

Credentials

A small badge icon with a shield shape in muted blue tones on a light background

Systems Administration

Deep experience with Linux (RHEL, SLES, CentOS), high-availability clusters, and STONITH configurations.

A small badge icon with a gear shape in muted blue tones on a light background

Cloud Infrastructure

Practical knowledge of AWS EC2, reserved instances, and cost analysis for cloud vs. on-premises deployments.

A small badge icon with a code symbol in muted blue tones on a light background

Development

Proficient in F#, PHP (Symfony), and cross-platform tooling including Mono and MonoDevelop on OSX.

Studies

F# & Functional Programming

Self-directed, 2012

Explored strongly typed functional programming with F# on OSX using the Mono runtime. Published a detailed getting-started guide covering toolchain setup and cross-platform game development research.

High-Availability & Cluster Management

Professional Development, 2009

Configured and documented crm_mon email alerting for STONITH events on SLES11-HAE clusters, integrating with Nagios monitoring for production environments.

Hardware & Storage Performance

Ongoing

Conducted hands-on benchmarking of SATA/SAS RAID controllers including HighPoint RocketRaid 2740 and LSI/SuperMicro AOC-USASLP2-H8iR, comparing against software RAID configurations.

Skills

A small icon representing a server with clean geometric lines in slate blue

Linux Administration

RHEL, SLES, CentOS — package management, kernel tuning, HA clustering, and monitoring integration.

A small icon representing a cloud shape with clean geometric lines in slate blue

Cloud Architecture

AWS EC2, reserved-instance planning, cost modeling, and hybrid infrastructure strategy.

A small icon representing code brackets with clean geometric lines in slate blue

F# & .NET/Mono

Functional programming on OSX, MonoDevelop toolchain, and cross-platform game-dev exploration.

A small icon representing a database cylinder with clean geometric lines in slate blue

PHP & Symfony

Web application development with the Symfony framework and the broader PHP ecosystem.

A small icon representing a storage drive with clean geometric lines in slate blue

Storage & RAID

SATA/SAS controller evaluation, md RAID configuration, and performance benchmarking.

A small icon representing a shield with clean geometric lines in slate blue

High Availability

Pacemaker, STONITH, crm_mon alerting, and Nagios integration for production cluster monitoring.