没有不值得去解决的问题,也没有不值得去学习的技术!

Analyzing File Size Limits in Template File Validation Rules

Searching for .php files in the WordPress themes directory, the largest file size is 1.59 MB. Searching for .js files in the WordPress themes directory, the largest file size is 402 KB. Searching for .png files in the WordPress themes directory, the largest file size is 911 KB.

1. Referring to the template source code editor in the Shopify admin, when uploading a file larger than 50 MB, the response is 413 Request Entity Too Large. This is likely limited by the client_max_body_size 50M setting in the Nginx server block. See Figure 1.

Referring to the template source code editor in the Shopify admin, when uploading a file larger than 50 MB, the response is 413 Request Entity Too Large. This is likely limited by the client_max_body_size 50M setting in the Nginx server block.
Figure 1

2. When uploading a 48.5 MB CSS file, it took 2 minutes to upload successfully with a 200 response. See Figure 2.

When uploading a 48.5 MB CSS file, it took 2 minutes to upload successfully with a 200 response.
Figure 2

3. When adding or editing a 368 KB liquid or json file, the response is 422. The template content exceeds the 256 KB limit. See Figure 3.

When adding or editing a 368 KB liquid or json file, the response is 422. The template content exceeds the 256 KB limit.
Figure 3

4. After adding a blank file named 1.css.liquid under Assets, editing it to add 1.81 MB of content succeeds upon saving.

5. When editing Hueman: Homepage Template (index.php) in the WordPress admin under Appearance – Theme File Editor, adding 736 KB of content updates successfully with a 200 response. It took 1.5 seconds. See Figure 5.

When editing Hueman: Homepage Template (index.php) in the WordPress admin under Appearance - Theme File Editor, adding 736 KB of content updates successfully with a 200 response. It took 1.5 seconds.
Figure 5

6. When adding more than 50 MB of content, the response is 502. Something went wrong. Your changes may not have been saved. Please try again. You may also need to manually fix and upload the file via FTP. Checking the response in the Network tab shows: Failed to load response data: Request content was evicted from inspector cache. Confirm that the newly added content has been successfully saved to the template file by reviewing the template file content again. See Figure 6.

When adding more than 50 MB of content, the response is 502. Something went wrong. Your changes may not have been saved. Please try again. You may also need to manually fix and upload the file via FTP. Checking the response in the Network tab shows: Failed to load response data: Request content was evicted from inspector cache. Confirm that the newly added content has been successfully saved to the template file by reviewing the template file content again.
Figure 6

7. When adding 46.5 MB of content, the response is 502. This continued down to 22.8 MB, all returning a 502 response. At 22.7 MB, the response was 200.

8. Searching for .php files in the WordPress themes directory, the largest file size is 1.59 MB. Searching for .js files in the WordPress themes directory, the largest file size is 402 KB. Searching for .png files in the WordPress themes directory, the largest file size is 911 KB. See Figure 7.

Searching for .php files in the WordPress themes directory, the largest file size is 1.59 MB. Searching for .js files in the WordPress themes directory, the largest file size is 402 KB. Searching for .png files in the WordPress themes directory, the largest file size is 911 KB.
Figure 7

9. Finally, I established my own rules: the file size limit for the Assets directory is 10 MB (the MySQL MEDIUMBLOB limit is 16 MB), the file size limit for the Locales directory is 2 MB, and the file size limit for other directories is 512 KB.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系