Plight of Chinese Developers

Lately, due to personal requirements, I once again delved into domestic VPS and Serverless (cloud functions). What was previously a problem-free service for local debugging, upon submission, either struggles to install dependencies, requiring meticulous troubleshooting with frequent switches to domestic sources, or it moves at a snail’s pace, wasting copious amounts of time on network delays.

I profoundly comprehend that the three major obstacles hindering the progress of developers in mainland China are, in my estimation, the network, the network, and, to put it bluntly, the darn network!

let-the-bullets-fly

Of course, this article is not meant to instruct you on how to resolve network issues but rather to outline my approach to dealing with such situations.

Ingress

The entry point is my blog, because I previously migrated to Cloudflare Pages and made specific provisions for both domestic and international acceleration. Upon my analysis, the initial speed of mainland CDN sourcing from Cloudflare Pages is less than ideal. Creating another mainland COS (China Object Storage) replica doesn’t yield substantial benefits.

Furthermore, GitHub’s ecosystem is incredibly user-friendly, especially when combined with Actions. Although I attempted Tencent Cloud’s Serverless, the experience was unsatisfactory primarily due to network issues that prevented seamless integration with GitHub’s ecosystem. Every time I made changes, I had to use Go, cross-compile and package it locally, manually upload binaries to the official console, and configure various triggering conditions. What an ordeal! 😰

Objectives

Keep it simple and effective.

Based on current data statistics, it turns out that separate acceleration is no longer necessary. Therefore, I consolidated everything back to GitHub + Cloudflare Pages, centered around GitHub for code management and service construction.

Concerned about access speed? If you can use GitHub normally, then speed won’t be an issue 🤓.

Execution

For this site, there are essentially two aspects to consider: site content itself and image resources.

Both of these are hosted on Qiniu and support HTTPS. As these are replicas with their own caching systems, there may be brief inconsistencies each time an update is made. Currently, I resolve this using GitHub Actions by invoking their APIs 😂.

Regarding site content, thanks to previous DNS-based routing configurations, I simply removed the routing strategy.

As for image resources, after comparing various solutions, I realized that my requirements for image resources are actually quite minimal. Even now, I have fewer than 90 images. Therefore, I can fully manage them alongside my blog by encoding them into lossless WebP format and storing them in the repository.

webp-usage

Image Processing

  1. Retrieving image resources: Qiniu’s COS console does not support bulk data downloads, and you can’t directly download directories; you have to laboriously click into each directory and download the files one by one 💩. Fortunately, they provide a script tool for batch downloading.

  2. Encoding data into WebP: To minimize adaptation work, I kept the directory structure unchanged and used cwebp to encode files into WebP format (using -lossless for lossless encoding). I wrote a simple script to expedite the process.

  3. Resource construction and processing: I easily handle custom deployment tasks using GitHub Actions and Cloudflare Wrangler tool.

  4. DNS switch: Finally, I switched DNS from Qiniu to Cloudflare.

Conclusion

With this migration completed, I only need to maintain one GitHub repository; everything else is automatically handled by Cloudflare. Additionally, I’ve discovered that Cloudflare excels in handling HTTP protocols with standard and exceptional precision. I’ve even gained knowledge about protocol details from this experience, making it more reliable and less of a hassle compared to handling it myself 😴.

To simplify image handling, I also made adjustments to PicGo’s image plugin picgo-plugin-compress-webp-lossless, mainly by tweaking the WebP encoding parameters to lossless, facilitating storage. It’s already published on npm, so you can easily install it through the plugin settings.

Final Thoughts

Every time I encounter an issue caused by network problems or problems that become time-consuming due to network issues, it frustrates me. Time is wasted on meaningless matters, sometimes even less productive than simply using a smartphone.

From the days of smooth operations to the present challenges, it’s not a network issue; it’s my issue, and it may be your issue too.

Actually, after completing these operations, my actions won’t bring anything new to China’s network; on the contrary, it might reduce its diversity a bit. But who cares?

But I know I’m not the first, and I certainly won’t be the last.