How you manage static content?

Posted December 28, 2020 462 views
PHPDigitalOcean Droplets

Hello i have 2 hosting with loadbalancer..

Before using loadbalancer, to server static content i use json or txt generate from localdatabase..

When i use LD i cant use same trick because when i update my json using link, it always update one json not both because of LD redirect to one of it..

I want to how you guys server static content? I prefer some way that cost less…

Because i have 2 hosting and 1 db hosting. So i prefer cheap way to do it, but if you think spend money is a must then its ok, i accept all input.. Thx

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

The easiest solution that requires the least amount of overhead is to serve your static content from Spaces Object Storage. This way all of your static content is read, written, and served from a single location and you can also enable the built in CDN to improve download speeds for your users.

This also means you don’t have to worry about a particular droplet and access to the data, or how to update static files when you have multiple droplets as everything is written to a central location through a managed service.

  • what happend if said storage down?
    because the storage stored in 1 place right?

    • If spaces in an entire region is down it would be unavailable.

      However, if you have CDN enabled on your spaces bucket then the CDN caches the most requested files whenever they are served, so it is possible that during a downtime if you have files that are repeatedly accessed they would be served by the CDN even with spaces offline.

      Technically you can also load objects into Spaces in two separate regions and then layer in a different CDN which would use both Spaces addresses as origins to pull content from.

      This way even if one is down the CDN would automatically try to pull from the second one, aside from having it’s own internal cache, and then only if both Spaces are down, and there is no cache for that object in the CDN, would the asset fail to load.

      • hmm, interesting..
        this is new to me..

        for now i use json file between server.
        so i 1 server update, it pass json to other server to write into their own storage..

        is it right things to do?
        is there any downside in long-term?