Fast 404 can be enabled for performance improvements under advanced settings in the settings.php file, see https://www.drupal.org/node/76824.
The discussion noted that enabling fast 404 will break image styles and added styles to the path exceptions. However, it did not include any documentation or information that fast 404 will break the default inline images if private download method is used.
I propose to either
- Add documentation about images and private download method
- Better: to include the default path in the exceptions such as
$conf['404_fast_paths_exclude'] = '/\/(?:styles)|(?:system\/files)\//';
This would ensure that core functionality continues to work if fast 404 is enabled with just default settings.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 2455057-20.patch | 1.42 KB | michaellenahan |
| #14 | 2455057-14.patch | 1.44 KB | michaellenahan |
| #8 | 2455057-8.patch | 920 bytes | michaellenahan |
Comments
Comment #1
jhodgdonThat sounds like a reasonable thing to add to the documentation. Feel free to edit the page -- it is part of the Community Documentation. Moving this to the Documentation issue queue in case someone else wants to work on it.
Comment #2
jelo commentedShould we just have it in d.o or as part of the settings file itself? Right now it reads:
How about adjusting this paragraph to:
404_fast_paths_exclude: A regular expression to match paths to exclude, such as images generated by image styles, or dynamically-resized images. If you need to add more paths, you can add '|path' to the expression. If you use private file download method and expect images to display inline, you will have to add "|(?:system\/files)" to the excluded paths.
Comment #3
jhodgdonHm. Yeah, maybe it should be added to the settings.php file... feel free to move this back to Drupal Core. If you do, set the version to 8.0.x please, since our policy is to fix API documentation in Drupal 8 first, then backport to D7.
Comment #4
jelo commentedSorry. It might be too early in the morning for me, but I seem unable to find the appropriate project to change it back to in the autocomplete. @jhodgdon: can you set it back?
If we open this discussion, I think it would be great to evaluate if it should be only in the settings file as documentation or by default be added to the path exclusions.
Thanks, J.
Comment #5
jhodgdonThere we go...
Comment #6
michaellenahan commented+1 to having the private file system added by default to the path exclusions.
A note in the docblock comment about the private file system would help as well.
It took me a very long time today to work out why my images weren't showing after I enabled the private file system. Everything worked fine on the stage server, but on the live server I was getting 404s.
Until I came across this page I wasn't aware of fast 404, now I guess I've learned my lesson :), but having the private file system excluded by default seems like a "sane default" to me. (Unless there are downsides I haven't considered yet).
Comment #7
jelo commentedWelcome to the club. It took me a long time to figure this out. As a minimum I would suggest to enter the documentation in the file itself. I guess this could be done as a patch submission? I am not setup for patch submissions yet. Michael, would you be able to submit the text change as a patch submission?
404_fast_paths_exclude: A regular expression to match paths to exclude, such as images generated by image styles, or dynamically-resized images. If you need to add more paths, you can add '|path' to the expression. If you use private file download method and expect images to display inline, you will have to add "|(?:system\/files)" to the excluded paths.
Does it need more feedback from the community to change the default or should that be submitted as a patch as well?
Comment #8
michaellenahan commented@jelo --- with pleasure! Here's the patch.
I agree that documenting the issue is a good minimum step.
Comment #9
michaellenahan commentedComment #10
jhodgdonDocs look great! However I think we should really consider adding this to the defaults too?
Comment #11
jhodgdonIn which case we should move this to the "base system" component as it is not just docs.
Comment #12
jelo commentedI am all for adding this to the defaults. I don't think it makes sense to break inline images in private file download mode purposefully.
Michael, based on Jennifer's suggestion, could you roll another patch that adjusts the default exclusion path to
$conf['404_fast_paths_exclude'] = '/\/(?:styles)|(?:system\/files)\//';We then may have to change the text to read as follows:
* - 404_fast_paths_exclude: A regular expression to match paths to exclude,
* such as images generated by image styles, the default path to private file downloads to enable inline image display, or dynamically-resized images.
* If you need to add more paths, you can add '|path' to the expression.
Comment #13
jhodgdonThat seems like a good course of action to me, thanks!
Comment #14
michaellenahan commentedHi, sorry it took a while to get round to this. Here is the patch: I rewrote the docblock comment slightly as well.
Comment #15
jhodgdonThis looks good to me, thanks! However the suggestions in #12 are not all there, and they seem like good additions to the documentation?
Comment #16
michaellenahan commentedWell, I re-wrote the suggestion in #12 slightly, so that it includes the sentence:
"The default pattern provided below also excludes the private file system."
For me, that covers the intention in #12. I made it a separate sentence because I thought that would be easier to read. It also makes it easier to understand that there are two parts to the exclusion - firstly for image styles, then secondly for the private file system.
...
Comment #17
jhodgdonOh, right! Sorry about that. Must have been Monday. I think this is good then!
Comment #18
alexpottCommitted 6475b82 and pushed to 8.0.x. Thanks!
Comment #20
michaellenahan commentedHere's the Drupal 7 backport.
Comment #21
jhodgdonThanks! Yes, backporting this seems reasonable.
Comment #22
David_Rothstein commentedHm, so as far as I can see this is only needed by sites that put the drupal_fast_404() line in settings.php. For other sites, the current setting would actually be preferable and more performant.
However, we already excludes 'styles' for all sites, and if you're using private files the performance gain from fast 404 is less important anyway, so yeah, let's do this and then maybe see if we can follow up with another issue to prevent Drupal from excluding anything except when drupal_fast_404() is actually called from settings.php.
Committed to 7.x - thanks!
Comment #24
David_Rothstein commentedCreated a new issue as described above.