What's new on Staticaly?


#1

2018 has passed, and 2018 is a good start for Staticaly, let’s discuss what’s new at Staticaly in 2019.

Currently Staticaly has managed to serve up to more than 70 million requests per month which consumes more than 7 TB of data, complete can be seen on the stats page.

At Staticaly, we believe that static files should not be slow, so we continue to develop to make static files really fast and suitable for production needs.

After success serving requests for files from GitHub, GitLab, Bitbucket, Favicon and image from URL, there are some additional features, what are the things? Let’s see.

1. Support for WordPress

Now you can use Staticaly for WordPress, we add support to serving static files for WordPress, cores and plugins. This is intended to reduce static file requests to the origin server, because all will be served by Staticaly CDN.

Endpoint

Core

https://cdn.staticaly.com/wp/c/:VERSION/:FOLDER/:FILE
https://cdn.staticaly.com/wp/c/5.0.2/wp-includes/js/jquery/jquery.js

Plugins

https://cdn.staticaly.com/wp/P/:PLUGIN_NAME/:VERSION/:FILE
https://cdn.staticaly.com/wp/p/jetpack/6.8.1/css/jetpack.css

Currently there is no official plugin available yet, this is something we will do in the future, but if you want to help make it possible, feel free to contact us via contact page.

2. Containerization

Now the Staticaly core program runs on containers in Docker, this option facilitates our development in the application. Thanks Docker!

3. More Backend Servers

Thanks to all sponsors who support infrastructure, Staticaly currently has a total of 6 core backends spread across various countries such as Indonesia, Singapore, China, Europe, and US. These backends are useful for retrieving raw files from raw.githubusercontent.com, gitlab.com, bitbucket.org, and images from the URL, storing them and sending them on the CDN.

4. New Sponsor

A list of sponsors can be found on the sponsor page.


And above are some updates for Staticaly. Thank you for trusting Staticaly for your static file solutions, Support us by Star our repo, we will continue to make it even better. :wink:


#2

Just an idea about the plugin. We could create a plugin that simply convert the asset URL to Staticaly URL version. So, adding this plugin will boost the asset loading, and removing this plugin will revert the asset URL to its original URL.

There should be some filter function documented in the WordPress docs that can be used to alter or replace the asset URL passed in the function argument.

If no, there still a way though. That is, by manipulating the output buffer of HTML page using RegExp and such to extract the asset URL from HTML markup.


#3

I am still learning about this and want to find the best way to not disrupt wordpress performance, do you have suggestions for filters that should be used?

@ardyfeb also working on this plugin, any updates?


#4

Each plugin and theme has its own static file URL spec and it is possible to have a constant URL pattern, so it is possible to change the existing URL into the CDN URL version from Staticaly, for example, here I use simple regex pattern to change the default URL structure of a WordPress site asset into the CDN URL structure of Staticaly.

The following is the PHP version. You need to find a way to get every asset URL that appears on the page output so you can put them as parameter value of $x:

function convert_core_url($x) {
    return preg_replace('/^https?:\/\/[^\s\/]+\/wp-includes\/([^?]+)\?ver=([^&]+)$/', 'https://cdn.staticaly.com/wp/c/$2/wp-includes/$1', $x);
}

function convert_plugins_url($x) {
    return preg_replace('/^https?:\/\/[^\s\/]+\/wp-content\/plugins\/([^\/?]+)\/([^?]+)\?ver=([^&]+)$/', 'https://cdn.staticaly.com/wp/p/$1/$3/$2', $x);
}

// TODO: You need to have a CDN URL for theme assets!
function convert_themes_url($x) {
    return preg_replace('/^https?:\/\/[^\s\/]+\/wp-content\/themes\/([^\/?]+)\/([^?]+)\?ver=([^&]+)$/', 'https://cdn.staticaly.com/wp/t/$1/$3/$2', $x);
}

The easiest way would be to search for <img>, <link>, <script> and <style> tags to get the URL from it’s src attribute.


#5

Maybe I can help in creating the plugin functionality but I need the basic boilerplate from you as I don’t know anything much about WordPress API. Here’s a good start.


#6

Hey @ta.tau.taufik,

Sorry for such a late reply.

What about this?

<?php

function staticaly_html_output($buffer) {

    $search = array(
        '',
    );

    $replace = array(
        '',
    );

    $buffer = preg_replace_all($search, $replace, $buffer);

    return $buffer;
}

ob_start('staticaly_html_output');

#7

No, it’s not about the PHP boilerplate but specific to WordPress plugin file structure and content boilerplate.


#8

Ah got it, I went ahead and upload the code on GitHub for better tracking, could you please check? https://github.com/marsble/wp-staticaly


#9

Okay. So, from there I could play around with the Staticaly_Loader class instance.