Skip to content

WP Stateless

    WP Stateless is a plugin which syncs your media with Google Cloud Storage.

    This is an old plugin, and while it may have been removed from wordpress, I still prefer this plugin over some of the newer and more complex plugins.

    Setting up the plugin is easy. First create a cloud storage bucket. I recommend naming the bucket after a subdomain you want to use like cdn.example.com and adding the CNAME c.storage.googleapis.com to your subdomains DNS.

    On your newly created cloud storage bucket, you will need to add a permission with the principal allUsers and the role Cloud Storage > Storage Object Viewer to make the media public to users. You will also need to set Access control to Fine-grained for wp-stateless to work properly, otherwise it may fail to upload media.

    Next thing on google cloud, is to go to APIs & Services > Credentials, and Create Credentials > Service account. You can name it anything you want to. When granting permissions, you need to add the role Cloud Storage > Storage Admin. I have tried Storage Object Admin, and that caused the plugin to fail to upload media, so it does need to be the regular Storage Admin.

    After creating your new Service Account Credentials, you will need to generate a key for it. Click on the credential you just created, and go to the KEYS tab and click ADD KEY > Create new key setting the key type to JSON. You will need to download the key file for later.

    Now, on your website, install and activate the wp-stateless plugin. If it asks, choose manual setup, or go to Stateless Settings under the Media tab.

    Under The Service Account JSON option, you will need to open the Service Account Credential Key you downloaded, open it in a text editor, and copy the contents (ctrl+a, ctrl+c). You will then need to paste it in the textarea on your website (ctrl+a, ctrl+v).

    Just above that option, you will see an option called Bucket, You will need to put the name of your cloud storage bucket, so wp-stateless knows what bucket to use.

    Down at the bottom, if you are using a CDN on a custom subdomain, you will want to add the full subdomain to the Domain option (https://cdn.example.com). I also recommend enabling the Cache-Busting option right under that.

    At the top, you should start with setting the Mode to CDN, since the media has Not been synced with google cloud yet. You may also want to set the File URL Replacement option to Enable Editor & Meta.

    Now Save Your Settings, and there should be a new tab called Sync. Go to this tab, and run Media Library Images, and Media Library Files to upload everything to the cloud. Before amusing everything is working, go back to your google cloud storage bucket, and check to see if the media was successfully uploaded. wp-stateless might Not warn you of permission errors. If you don't see anything, double check you followed the above steps correctly.

    If everything seems to be working properly, check your frontend media to see if it is loading from the CDN. Some page builders or post images might require you to re-select most images from the library, by unchecking and rechecking them, to update the url.

    Also clear the cache if you have one. If you don't have a cache, than that should have been your first thought to improving site performance and reducing bandwidth usage. Click Here for a good cache plugin, if you don't have one yet. Note: having more than one cache plugin, can actually slow down your site. Only use one.

    Now that everything is working, and you have verified All your media is loading from the CDN, and that Everything is on google cloud storage, you may choose to go back to your Stateless Settings under Media, and set the Mode to Stateless. Which will never store media on your local site, and reduce the amount of disk space and storage your website is usage. After that, you may want to run the sync method again, to be sure all the old media gets removed from your website, and is only on google cloud. You may also want to double check your media is loading properly one more time, just in case you missed anything.

    Congratulations

    Your website likely now runs faster, with less bandwidth usage, and probably with cheaper hosting costs on media storage. Enjoy.

    Leave a Reply

    Your email address will not be published.