Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Cloudfront CDN #87

Merged
merged 6 commits into from Mar 29, 2016
Merged

Cloudfront CDN #87

merged 6 commits into from Mar 29, 2016

Conversation

rohitdatta
Copy link
Member

Changes proposed in this pull request:

  • Use the CloudFront CDN (or really any CDN) to serve static files

Have you made sure to add:

  • Tests
  • Documentation

None necessary. CloudFront works right out of the box

Screenshots and GIFs

Deploy notes

Must add the CDN_URL config variable to Heroku and set it to our CDN URL

Any Additional Information

@rohitdatta rohitdatta changed the title Cloudfront cdn Cloudfront CDN Mar 20, 2016
@fiatjaf
Copy link
Contributor

fiatjaf commented Mar 21, 2016

This is just a way to generate CDN urls with our current url_for? But how will the CDN know which files to serve? I thought these Flask helpers were magical pieces of software that automatically uploaded/notified the CDNs of our static files on each deploy.

@rohitdatta
Copy link
Member Author

You can setup CloudFront to either pull from an AWS bucket or to get it from a server, which is what I chose (formspree.io). If you go to d1ma8knj6twvg6.cloudfront.net, you'll see that it's mirroring the Formspree site directly. As a result, it will replace the static URLs with those pulled from CloudFront. However, after I submitted this I pushed to my Heroku and learned that some of the files in the portal seem to be pulling in files that it cannot access, even though it works locally, so this cannot be merged yet.

@rohitdatta
Copy link
Member Author

The funny part is that it shouldn't be passing the Travis CI tests if it can't access the portal since the tests check the status code returned

@fiatjaf
Copy link
Contributor

fiatjaf commented Mar 21, 2016

That's much better than I thought.

@rohitdatta
Copy link
Member Author

Looks like it's a font issue that's causing all these problems, so I'll try to fix the CloudFront distribution and see if that fixes things.

@rohitdatta
Copy link
Member Author

The issue of it not loading on Heroku was related to me forgetting to upgrade my Heroku DB, not CloudFront. I fixed the issue by using the CDN provided by Ionicons for importing the icons. This should solve all the issues and is better anyways since it simplifies us from loading the icons ourselves from our own folder. If we wanted to, we could also just use Font Awesome for the icons and not use Ionicons at all, but that's a decision for later.

@fiatjaf
Copy link
Contributor

fiatjaf commented Mar 21, 2016

Are we using two different sets of icons?

@rohitdatta
Copy link
Member Author

Yes we currently have Ionicon and Font Awesome. I would say we should probably use Font Awesome since given its popularity, it would be more likely to be future proofed in the event of any browser changes.

@rohitdatta
Copy link
Member Author

@fiatjaf Is this ok to merge?

@fiatjaf
Copy link
Contributor

fiatjaf commented Mar 28, 2016

Sorry, I think I was waiting for you to solve some old issue you mentioned, but you had already solved it a long time ago.

How will this affect the experience of people hosting Formspree without a CDN or, more important, running Formspree locally for development?

@rohitdatta
Copy link
Member Author

If the config var for CDN_URL is not set then it will not load from the CDN and instead load from the API_ROOT as it currently does

@fiatjaf
Copy link
Contributor

fiatjaf commented Mar 29, 2016

So let's merge it!

@fiatjaf fiatjaf merged commit eb48385 into formspree:master Mar 29, 2016
@rohitdatta rohitdatta deleted the cloudfront-cdn branch April 6, 2018 21:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants