elementor/wp2static-addon-s3

CloudFront Invalidation Never Created

austinlangdon opened this issue · 2 comments

Hello! I've been working with v7 for a couple of days, testing it out with S3 + CloudFront deployment. It's looking great!

I've run into an issue with the deployment.

S3 successfully finishes and then the deploy job attempts to create a CF Invalidation - logging on "Invalidating all CloudFront items".

But then nothing happens. The deploy job just stays in processing until I eventually delete the jobs/cancel them. I also check CloudFront and an Invalidation is never created.

Is this a known issue? I also checked my PHP server logs and not seeing any errors.

I recommend just setting a default cache time of 15-20 minutes and letting the cache expire naturally, not invalidating anything at all. The ideal use of CloudFront is to never invalidate anything, as invalidation is expensive and can take up to 20-30 minutes to take effect anyways. Invalidation costs $0.50 per thousand files currently, so a default WordPress install with about 3000 files costs $1.50 per deploy. You are not supposed to be invalidating things in normal usage, and certainly not the entire distribution (which is what WP2Static currently tries to do).

That said, my recommendation works best when the user understands that it's by design and doesn't expect instantaneous updates. The most recent speed info I found is that "Object invalidations typically take from 60 to 300 seconds to complete.", which is a nice speed improvement that might be more palatable to some users. I may get a chance to work on this in the next week or two, both testing it and doing targeted invalidations rather than clearing the whole cache.

Thank you for the response @john-shaffer. Indeed CloudFront can be quite expensive. We will set TTL for 15-20 mins per your recommendation. I just wanted to confirm that this isn't a user error.

And great work on this project so far. I have a digital agency and we look forward to rolling out v7 to our clients!