Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>So, here's my question: What option is better (efficiency-wise and otherwise) and why?</p> </blockquote> <p>If every resource has to run through a PHP based check, as you say in your comment:</p> <blockquote> <p>some resources are only available to logged in users, so I get to check cookies and login state first, then I serve them with readfile().</p> </blockquote> <p>then you can indeed use PHP-side logic to handle things: A PHP instance is going to be started anyway, which renders the performance improvement of parsing URLs in Apache largely moot.</p> <p>If you have static resources that do <em>not</em> need any session or other PHP-side check, you should absolutely handle the routing in the .htaccess file if possible, because you avoid starting a separate PHP process for every resource. But in your case, that won't apply. </p> <p>Some ideas to increase performance: </p> <ul> <li><p>consider whether really <em>every</em> resource needs to be protected through PHP-based authentication. Can style sheets or some images not be public, saving the performance-intensive PHP process? </p></li> <li><p>try minifying resources into as few files as possible, e.g. by minifying all style sheets into one, and using CSS sprites to reduce the number of images.</p></li> <li><p>I've heard that <a href="http://nginx.org/" rel="nofollow">nginx</a> is better prepared to handle this specific kind of scenario - at least I'm told it can very efficiently handle the delivery of a file after the authentication check has been done, instead of having to rely on PHP's <code>readfile()</code>.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload