AWS add balance without paypal AWS CloudFront CDN Setup and Support
Why You’re Probably Overcomplicating CloudFront (and Why That’s Okay)
Let’s be honest: AWS CloudFront feels like that one friend who shows up to dinner with a spreadsheet of wine pairings, three backup chargers, and a laminated flowchart titled ‘How to Ask for Salt Without Offending the Host.’ It’s powerful, meticulous, and slightly intimidating. But here’s the good news — you don’t need to master all 47 cache headers, 12 TTL tiers, and the existential dread of TTL inheritance to get real value out of it. In fact, most teams go live with 80% of CloudFront’s power using just five well-chosen settings. This isn’t a certification cram session. It’s your field manual — written by someone who once invalidated the wrong path pattern and served a 404-heavy version of their production site for 37 minutes while whispering apologies to their SRE team.
Your First Distribution: Less Clicking, More Clarity
Start in the AWS Console, sure — but skip the ‘Create Distribution’ wizard’s cheerful ‘Let’s Get Started!’ button. Instead, click ‘Get Started’ only after you’ve answered three questions:
- What’s my origin? S3 bucket? ALB? API Gateway? EC2? (Spoiler: If it’s EC2, reconsider — seriously.)
- Do I need custom domains and HTTPS? If yes, grab your ACM certificate *before* creating the distribution — not after. CloudFront won’t let you attach an ACM cert from another region, and yes, we’ve all tried.
- What am I optimizing for? Static assets? Dynamic APIs? Video streaming? Each has wildly different cache behavior defaults — and blindly accepting ‘Use Recommended Settings’ is like ordering ‘Chef’s Surprise’ at a restaurant where the chef is an algorithm trained on 2017 blog posts.
Pro tip: Use the aws cloudfront create-distribution CLI command with a JSON file instead of the console. Why? Because you’ll version-control it, reuse it across environments, and avoid accidentally enabling ‘Compress Objects Automatically’ on a legacy PDF endpoint (true story; compression broke digital signatures).
Origin Setup: Don’t Let Your Bucket Hide Behind a Proxy
If your origin is S3, do not use the bucket’s public website endpoint (e.g., https://my-bucket.s3-website-us-east-1.amazonaws.com). Why? Because it bypasses CloudFront’s security controls, disables some cache features, and — worst of all — forces HTTP-only redirects if you later add HTTPS. Instead, use the S3 REST endpoint (my-bucket.s3.us-east-1.amazonaws.com) and configure CloudFront to use ‘S3 Origin’ type. Bonus: enable ‘Origin Access Identity’ (OAI) to block direct S3 access — unless you enjoy surprise traffic spikes from scrapers who found your bucket URL in a GitHub commit.
Cache Behaviors: Where Magic Meets Misunderstanding
CloudFront doesn’t cache everything by default — it caches only what you tell it to, and only if your origin sends appropriate headers. The default cache behavior (path pattern *) uses ‘CachingDisabled’ unless you change it. So step one: switch to ‘CachingOptimized’. Step two: stop treating ‘Min TTL’, ‘Default TTL’, and ‘Max TTL’ like astrology. They’re not mystical — they’re fallbacks. Here’s how they work:
- If your origin sends
Cache-Control: max-age=3600, CloudFront honors it — full stop. - If your origin sends no caching headers? CloudFront falls back to Default TTL.
- If your origin sends
Cache-Control: max-age=86400, but your Max TTL is set to 3600? CloudFront caps it at 3600. Yes, it overrides your origin. (Yes, this breaks things. Yes, we’ve shipped that.)
Create separate cache behaviors for static assets (/static/*, TTL 31536000), APIs (/api/*, TTL 0), and HTML (*.html, TTL 60–300). And never — ever — apply ‘Cache Based on Selected Request Headers’ to * without whitelisting only the headers you actually need. We once enabled ‘All Headers’ for a GraphQL endpoint. Result? 12,000 unique cache keys per second. Cost spike: $2,300/month. Lesson learned: cache key entropy is silent, deadly, and billed hourly.
HTTPS, Certificates, and That One Time We Got HSTS Wrong
You want HTTPS. Good. CloudFront supports it — but only with ACM certificates in us-east-1. Yes, even if your entire stack lives in eu-west-1. No, it’s not a bug — it’s AWS’s idea of ‘global service coordination’. Import your cert into us-east-1 ACM first. Then, when configuring your distribution, select ‘Custom SSL Certificate’ and pick it. Don’t choose ‘Redirect HTTP to HTTPS’ *and* ‘Viewer Protocol Policy: HTTPS Only’ — that’s redundant and confuses new hires. Pick one. We prefer ‘HTTPS Only’ — cleaner, fewer redirect hops, better for SEO and Lighthouse scores.
And please, please, please test HSTS before enabling it globally. Set max-age=300 first. Wait 5 minutes. Confirm it works. Then bump to 31536000. Because once you set max-age=31536000 and forget the ‘includeSubDomains’ flag, every internal dev tool with a self-signed cert stops loading — including your local Storybook instance, your mock API server, and the coffee machine’s admin page (if it has one).
AWS add balance without paypal Invalidation: The Emergency Fire Extinguisher (That Takes 10 Minutes)
Invalidation isn’t instant. It’s fast — but not that fast. Expect 1–10 minutes for global propagation. So don’t invalidate /index.html and then tweet ‘Site updated!’ at T+30 seconds. Also: avoid wildcards like /assets/* unless necessary. Each invalidation request consumes quota (1,000 paths per month free), and overusing * burns through it faster than a toddler with a glitter bomb. Prefer precise paths: /assets/js/main.a1b2c3.min.js, /images/logo-dark.f4e5d6.svg. Bonus: use cache busting in filenames — it’s cheaper, faster, and more reliable than invalidation.
Logging, Monitoring, and the Art of Not Panicking
Enable CloudFront access logs. Send them to an S3 bucket — but make sure the bucket policy allows CloudFront to write (yes, there’s a specific IAM permission for that). Then use Athena or OpenSearch to query them. Look for patterns: high 4xx rates on /api/health? Maybe your health check is too aggressive. Spikes in 504s? Origin timeout too low. Consistent 304s? Your cache headers are working beautifully.
Pair logs with CloudWatch metrics: Requests, BytesDownloaded, 4xx/5xxErrorRate, and — crucially — UpstreamLatency. If upstream latency jumps but origin response time stays flat, your bottleneck is *between* CloudFront and origin — often DNS resolution or TLS handshake issues.
Real-World Support Scenarios (aka ‘How We Fixed It at 2 a.m.’)
‘My images load slowly — but only in Brazil’
Check your price class. If you’re using Price Class All but have no edge locations in South America, requests route to the nearest available node — often in US-East or Europe. Switch to Price Class 100 (US/EU only) *or* confirm South American locations are included. Also verify your origin isn’t geo-blocked — we once had a CDN serving blank GIFs because our image processor blocked requests from ASNs registered in São Paulo.
‘My POST requests return 405’
By default, CloudFront only forwards GET, HEAD, OPTIONS, and TRACE. To allow POST, PUT, DELETE — you must explicitly enable them under ‘Allowed HTTP Methods’ and, if needed, ‘Cached HTTP Methods’. And if you’re forwarding cookies or headers, ensure ‘Forward Cookies’ is set to ‘Whitelist’ or ‘All’ — not ‘None’. Yes, that 405 was your own fault. No, it’s not embarrassing. Everyone’s been there.
‘My cache isn’t updating — even after invalidation’
Check two things: (1) Did you invalidate the exact path, including case and trailing slash? /blog/ ≠ /blog. (2) Is your origin sending Cache-Control: private or no-store? CloudFront respects those — and won’t cache, no matter what your TTL says. Use curl with -I to inspect headers *from CloudFront*, not your origin directly.
Final Thought: CloudFront Isn’t a Magic Bullet — It’s a Tuning Fork
It won’t fix broken backend logic. It won’t compensate for unoptimized images. It won’t make your JavaScript bundle smaller. What it *will* do — brilliantly — is deliver what you *already have* faster, safer, and more reliably. Treat it like a precision instrument: configure deliberately, monitor constantly, tweak iteratively. And when something breaks? Breathe. Check the logs. Verify the headers. And remember: the person who wrote this article once deployed a distribution with Min TTL = 0, Default TTL = 0, and Max TTL = 0 — thinking ‘zero means infinite’. It didn’t. It meant ‘never cache’. We survived. So will you.

