Support the ongoing development of Laravel.io →
Requests Database Eloquent
Last updated 1 year ago.
0

Here's a great laravel package for CDN management, I think this is what you need:

https://github.com/Vinelab/cdn

Last updated 1 year ago.
0

There are two types of CDN workflows.

Origin Push CDNs require you to upload or "push" your files to the CDN yourself and use the CDN url to server them. If you request a file that wasn't uploaded it will result in a 404 error. This is a more common type of CDN and most any CDN will support this workflow. The cdn package linked to above would help you with this workflow.

In an Origin Pull CDN workflow you do not upload the files to the CDN yourself (though you generally can if you want to). You just link to the file using the CDN domain and if that file doesn't exist on the CDN servers it will download or "pull" it from your domain and will be available from then on. This is a lot easier to work with but not all CDNs support this workflow.

Amazon Cloudfront supports both workflows but if you serve the files directly from an S3 bucket without Cloudfront you will need to use the Origin Push workflow.

The biggest pain in using a CDN (especially with Origin Pull) is what to do when a file on the CDN changes. The CDN will continue serving the old version of the file until it expires.

The easiest way around this is to have the url of the file to change each time the file content changes. This will cause the CDN will download a new version of the file right away and no one will get the old version anymore regardless of caching settings.

I've written a package to help me with this that you might find useful. https://github.com/spekkionu/laravel-assetcachebuster

Last updated 1 year ago.
0

You can create a helper as described here: https://www.keycdn.com/support/laravel-cdn-integration This approach if fairly easy and you don't need to to upload anything if you're using a pull zone.

0

If you are having trouble integrating CDN in Laravel, then this guide will be helpful to you: https://www.cloudways.com/blog/integrate-cdn-in-laravel/

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.