Project

General

Profile

Actions

Bug #7997

closed

Transition from single cac-files.php file server to site-specific .htaccess directives

Added by Boone Gorges over 7 years ago. Updated about 7 years ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
WordPress (misc)
Target version:
Start date:
2017-04-20
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

Currently, all requests for uploaded files ([domain]/files/...) run through wp-content/cac-files.php, our custom router based on WP's old ms-files.php. We use cac-files.php primarily for access protection: we need to load the WordPress application to decide who should have access to what files. But this is totally unnecessary for sites that are publicly accessible. The result is a severe increase on server load and perceived performance, especially when requesting large numbers of files. (See for example #7985, where the lag is almost certainly due in part to the problem described here.)

I'd like to move to a system that looks like the following:

1. As in new WP Multisite installations, we don't rewrite uploaded file URLs by default, but allow Apache to serve them directly.
2. Non-public sites - which includes the main site, which needs to protect forum attachments and other files - will have an .htaccess file in their site-specific blogs.dir directory. This file will redirect all requests to a download handler similar to cac-files.php (maybe even cac-files.php itself, I guess)

I think that the change to 1 is very easy (the UPLOADS constant or something like that). For 2, I'll need to write some custom code to generate .htaccess files. This routine will need to run whenever a site's privacy settings are changed, to either create or delete .htaccess, as appropriate. There'll also need to be a one-time update routine to create .htaccess files for existing sites. I've done a lot of this work for BuddyPress Docs and other projects, so it should be a somewhat reasonable port.

Posting here for any discussion (especially thoughts from Ray, in case I'm missing anything) before working on it. Putting in 1.12 for now, though it could be moved to a minor release, maybe early in the summer.


Files

cac-file-protection-backfill.php (455 Bytes) cac-file-protection-backfill.php Boone Gorges, 2017-09-28 03:35 PM

Related issues

Related to CUNY Academic Commons - Bug #7985: Commons lagging/disconnecting when uploading/inserting imagesResolved2017-04-19

Actions
Related to CUNY Academic Commons - Support #8602: Member not able to access Media tab on siteDuplicateBoone Gorges2017-08-28

Actions
Related to CUNY Academic Commons - Bug #9946: User and group avatars do not need to run through cac-files.phpResolved2018-06-18

Actions
Actions

Also available in: Atom PDF