Comments (15)
Unless my knowledge of Cloudfront is outdated, it should be possible to access only exact resources (e.g. /article/index.html) via the CDN. This means that HTTP GET /article should not work.
The only exception is the root resource, for which you can set a default document in your Cloudfront config (GET / -> /index.html).
from s3_website.
To confirm, Cloudfront supports default document only for the root resource: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DefaultRootObject.html.
from s3_website.
Hi,
My blog is hosted on CloudFront (michaelgallego.fr) and each page does not need the index.html ;-). I asked in CloudFront support, and each URL is considered as a different resource.
As a consequence, even www.example.com/about/ is considered as a different resource than www.example.com/about (note the leading slash). So as I access my pages without the index.html, invalidating those makes nothing.
I also realized two other things: when activating S3 website, if you visit "www.example.com/about", S3 makes a 302 redirection to www.example.com/about/ (once again, leading slash). In context of CloudFront, this means that CloudFront will also cache the redirection.
So the best way to do it is configured URL (with Jekyll for instance) so that trailing slash is always added at the end to avoid useless redirection AND invalidate the url WITHOUT the index.html.
from s3_website.
@laurilehmijoki , this is only the case if, when you create your CloudFront distribution, you choose the S3 bucket that Amazon automatically auto-complete you. But this is the wrong way to do. In fact you must copy-paste the website endpoint and not using the thing that Amazon auto-complete. I've made a blog post today about it (http://www.michaelgallego.fr/blog/2013/08/27/static-website-on-s3-cloudfront-and-route-53-the-right-way/).
This way, you also have the nice advantage of being able to use the 404 error page even in CloudFront :).
from s3_website.
This is interesting information. Thanks for pointers, @bakura10!
from s3_website.
No problem. Maybe adding an option to s3_website to include (or not) index.html would be awesome :D.
from s3_website.
A brute-force solution would be to invalidate all the three versions (plain, slashed and index.html'ed).
In this case, if you have the document /article/index.html
on your local file system, s3_website push
would invalidate three objects on Cloudfront. The objects would be
/article
/article/
/article/index.html
How does this sound to you?
What kind of problems do you see in this solution?
Ps. thanks for pointing out the deficiency in the S3 Cloudfront origin. At the moment the command s3_website cfg apply
creates a Cloudfront dist that marks the origin as an S3 bucket.
from s3_website.
It sounds good to me. The only problem is that some user who wrote lot of articles may reach the 1000 free invalidations. Or if you decide to change the permalibk it will invalidate a lot of things.
But I think it's a sane trade off :).
Envoyé de mon iPhone
Le 28 août 2013 à 06:54, Lauri Lehmijoki [email protected] a écrit :
A brute-force solution would be to invalidate all the three versions (plain, slashed and index.html'ed).
In this case, if you have the document /article/index.html on your local file system, s3_website push would invalidate three objects on Cloudfront. The objects would be
/article
/article/
/article/index.html
How does this sound to you?What kind of problems do you see in this solution?
Ps. thanks for pointing out the deficiency in the S3 Cloudfront origin. At the moment the command s3_website cfg apply creates a Cloudfront dist that marks the origin as an S3 bucket.
—
Reply to this email directly or view it on GitHub.
from s3_website.
I assume only a small part of the s3_website
users are affected by this invalidation issue. If we agree that it is better to serve most users well (invalidate only the /article/index.html
resources), we should not resort to the above-mentioned brute-force solution.
An alternative solution would be to add an s3_website.yml setting, where you could express that you want to invalidate all the three possible versions of the document (/article
, /article/
and /article/index.html
). The option could be cloudfront_brute_force_invalidate: true
.
Are you able to come up with a more elegant solution?
Ps. I welcome a pull request on this issue, once we agree on the solution. I'm not very likely to have the time to implement it.
from s3_website.
There is no need to invalidate the "/article" from my understanding, because S3 returns a 302 redirect to the url with "/".
Maybe we could have an option like "invalidate_root". If true => "/article/", otherwise "/article/index.html" ?
from s3_website.
Option cloudfront_invalidate_root: true
sounds good. It's unambiguous.
Let's add the "cloudfront" word into the option name, because the other Cloudfront-related options are also prefixed by that.
from s3_website.
Ok. I'm not a Ruby developer, but I'll try to come up with something tomorrow.
from s3_website.
I was able to come up with a rather simple implementation. It's released in version 1.4.0.
Please let me know if you spot any anomalities.
The commit is here: 9e0dd1e.
from s3_website.
I created the issue #30, because it is a part of the solution to the problem that @bakura10 has described in this issue.
from s3_website.
The fix looks perfect ;-).
Envoyé de mon iPhone
Le 28 août 2013 à 20:31, Lauri Lehmijoki [email protected] a écrit :
I was able to come up with a rather simple implementation. It's released in version 1.4.0.
Please let me know if you spot any anomalities.
The commit is here: 9e0dd1e.
—
Reply to this email directly or view it on GitHub.
from s3_website.
Related Issues (20)
- Private S3 bucket
- Configure custom response codes
- Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty HOT 4
- Compatibility with CloudFront "Origin Access Identity" usage?
- sun.security.validator.ValidatorException: PKIX path building failed HOT 1
- Support behind proxy HOT 1
- issues with deployment to us-east-2 region
- HTTP to HTTPS Redirection HOT 4
- cfg apply results in Aws::CloudFront::Errors::MalformedInput
- S3 listObjects is iterating through whole bucket
- Is it possible to redirect with query string
- Errors parsing ERB on s3_website push HOT 11
- Upload fail with accent characters HOT 1
- Exception in thread "main" java.lang.ExceptionInInitializerError HOT 6
- No redirects to configure for `bucket-name` bucket HOT 1
- Cant download
- Hugo Deploy: Migrating from S3 Website HOT 1
- Looking for new maintainers HOT 7
- Who's still using s3_website HOT 9
- unsupported Java version: 17 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s3_website.