Create a page with any broken image, css or js link.
Page renders as expected. But...
If you put the link in the browser url field you well get a standard Joomla Page Not Found page. Joomla has loaded the application stack to return a 404 Not Found page for every such broken link. And the browser has not used them - it only needs the 404 header. It would be faster and less resource demanding to let Apache return the 404 not found header.
Only relevant for Apache based sites
Add this at line 78 of htaccess.txt:
# and the request is not for an image, css or js file
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.jpeg|\.gif|\.svg)$ [NC]
Thanks for the extended comments for why this was not a good idea. I first noticed the problem when the debugger went through umpteen page load cycles. That was because I was using 'onerror' in the img tag to fetch images from the production server if they did not exist on the development server. I think end-users should at least know about the issue.
I have now read about water-marking, a topic I have never before needed to work with, and realise my suggestion for htaccess was not appropriate as a default. Once again thanks to mbabker for his comments. This issue can be closed (but I don't see a Close button).
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-02-07 12:50:13 |
Closed_By | ⇒ | alikon |
This should not be in the htaccess file by default. It is perfectly acceptable to have a PHP application generate these “static” resource types, even if less performant than serving a file; this opinionated of a rule in the default file would effectively make it impossible for extensions to serve responses for these file types if they were configured to be able to do so. You are welcome to customize the file and add any rule you like. Personally, I use rules to not try and boot my PHP applications if the request is for a path that contains these types of resources (so in Joomla that’d be the media and templates directories for starters) instead of not rewriting based on file extension (in one application we have a package that handles automatically generating the different variations (optimized sizes for different frontend slots, watermarked or not, etc.) of an uploaded image if that resource has not already been saved to the filesystem, a web server rule flat out not rewriting for JPG or PNG would keep this package from working at all).