parcel-bundler / website

šŸŒŽ Parcel website
https://parceljs.org
MIT License
351 stars 466 forks source link

Move to Cloudflare for CDN #59

Closed ryanworl closed 6 years ago

ryanworl commented 6 years ago

Right now the website is hosted from two IPs in AWS us-west-1 in San Jose.

This means everyone who wants to see the website around the world has to make requests all the way to San Jose, and the project is paying for AWS bandwidth, which is expensive.

The free tier of Cloudflare would fix both of these. Or any other CDN, I suppose, but it wouldn't be free.

davidnagli commented 6 years ago

+1

shawwn commented 6 years ago

Sounds like David just volunteered to do this. Good luck, I believe in you!

davidnagli commented 6 years ago

ahaha thanks! šŸ¤” šŸ˜‚

devongovett commented 6 years ago

website is using zeit now, not aws directly. zeit should be distributing things around the world automatically. see https://zeit.co/world

ryanworl commented 6 years ago

That Zeit World thing appears to be a DNS service. While Iā€™m sure it is fine, querying from a DNS server in Philadelphia (where I am) and the UK (for example) returns the same set of AWS IPs.

Unless I made a mistake here, even if the DNS is distributed, the servers hosting the content are not.

TimNZ commented 6 years ago

Sneaky use of this issue to segway into recommended recipe for cache busting file name generation and deployment.

Production builds utilise the filename of the relative path e.g.

<script src='./index.js'></script>

results in an index.js being generated, and other assets using a hash strategy for filenames.

I had a look at posthtml, that has a posthtml-cache plugin that generates uses a query string strategy to modify links, whereas I want a generated filename.

If I have a single publicUrl e.g. https://cdn/assets, will the generated filename hashes of assets ever result in conflicts in different builds which will result in browser caching serving an old version of an asset? If not, I can optimise uploading of assets to only upload files that doesn't already exist in the CDN.

Thanks for any insights you can provide. I don't have a lot of experience in CDN/deployment.

Anything Parcel can do to simplify this, or provide Recipes/Guides, is a big step up from everyone else leaving it to devs to figure out through pain.

devongovett commented 6 years ago

Just enabled zeit's new cdn, which uses cloudflare under the hood. https://zeit.co/blog/now-cdn