Using CDN to serve images and maybe .css and .js files

stantyan

Mar 22nd, 2017 07:29 PM

Hi,

Is it easy to implement CDN to serve images? Can you please help how can I do this?

devdojo

Mar 22nd, 2017 10:08 PM

You should be able to do this fairly easy. Laravel supports multiple file systems out of the box.

Take a look at this: https://laravel.com/docs/5.4/filesystem,

If you scroll down on how to use storage with S3, you will need to include this package in your laravel app:

league/flysystem-aws-s3-v3 ~1.0

I'll make sure to include it in the next release of the app as well.

Then inside of the config/filesystems.php you will need to change the storage you are using from local to s3.

I can add this to a future version so that way you can include this in your settings of your site and enable s3 instead of local storage.

Is s3 the CDN you are looking to use? Let me know :)

Thanks.

stantyan

Mar 23rd, 2017 10:04 AM

I want to use MaxCDN with Pull Zone method. Should I follow the same path as if I would use amazon s3? do I need to install any additional packages?

devdojo

Mar 23rd, 2017 02:19 PM

Hi Stantyan,

Right now it looks like Laravel supports Amazon s3 and Rackspace files. I'm sure we could get MaxCDN configured, but it may take a little custom work. If you are a subscriber on the DevDojo I can help out with that customization. Other then that s3 and Rackspace can be easily added and I will include the league/flysystem-aws-s3 and the league/flysystem-rackspace ~1.0 in the next release.

Thanks. Talk to you soon.

mark

Mar 23rd, 2017 08:21 PM

It would be possible to make a storage provider for Laravel that supports this.

A package that might help doing this: https://github.com/davidsneal/laravel-maxcdn

stantyan

Mar 23rd, 2017 08:38 PM

Thank you so much Mark!! I will try this.