Skip to content

Conversation

brandonpayton
Copy link
Member

What is this PR doing?

This updates the deploy workflow for WP Cloud so that PHP is no longer used to serve all Playground files.

What problem is it solving?

It is slow and unnecessarily burdensome on server resources to serve static files with PHP by default. This changes deployment so only resources that need redirects or custom headers are served via PHP. Most files do not need this treatment.

How is the problem addressed?

Most of the files are now located where nginx can serve them directly. Only files that need custom serving are set aside where nginx invokes PHP to serve files it cannot find.

Testing Instructions

@brandonpayton
Copy link
Member Author

Currently, this PR invokes PHP once per file to ask whether a file needs served by PHP. This is slow and will be changed to invoke PHP once to produce a filtered list of files that need custom treatment.

In addition, this PR currently symlinks most static files into the webroot so nginx can serve them directly. All files are actually stored in a secondary folder. This is a bit backwards. Instead, we should place all files that can served directly into the web root and only exclude the files that need special treatment.

I am working on both of these changes.

@brandonpayton
Copy link
Member Author

Currently, this PR invokes PHP once per file to ask whether a file needs served by PHP. This is slow

How slow? The deployment script was taking 10 minutes when tested directly via SSH. This can be made much faster.

@brandonpayton brandonpayton self-assigned this Apr 25, 2024
<?php

// Adapted from https://github.com/nginx/nginx/blob/d8a849ae3c99ee5ca82c9a06074761e937dac6d6/conf/mime.types
$mime_types = array(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reuse this list in the PHPRequestHandler class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamziel, sounds good.

My plan is to create a separate PR where we:

  • add a mime-types JSON file
  • import it in the TypeScript module for PHPRequestHandler
  • use the JSON to generate mime-types.php during deployment
@brandonpayton brandonpayton had a problem deploying to playground-wordpress-net-wp-cloud April 26, 2024 00:51 — with GitHub Actions Error
@brandonpayton brandonpayton had a problem deploying to playground-wordpress-net-wp-cloud April 26, 2024 01:04 — with GitHub Actions Error
@brandonpayton brandonpayton had a problem deploying to playground-wordpress-net-wp-cloud April 26, 2024 01:23 — with GitHub Actions Failure
@brandonpayton brandonpayton had a problem deploying to playground-wordpress-net-wp-cloud April 26, 2024 01:32 — with GitHub Actions Failure
@brandonpayton brandonpayton had a problem deploying to playground-wordpress-net-wp-cloud April 26, 2024 01:39 — with GitHub Actions Failure
@brandonpayton brandonpayton had a problem deploying to playground-wordpress-net-wp-cloud April 26, 2024 01:43 — with GitHub Actions Failure
@brandonpayton brandonpayton temporarily deployed to playground-wordpress-net-wp-cloud April 26, 2024 02:40 — with GitHub Actions Inactive
@brandonpayton
Copy link
Member Author

The latest changes cut the apply-update.sh run time from ~10min to ~10sec. ☺️

@brandonpayton brandonpayton merged commit c4b88f7 into trunk Apr 26, 2024
@brandonpayton brandonpayton deleted the skip-php-for-most-static-files-on-wp-cloud branch April 26, 2024 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment