Reputation: 1138
I'm sitting here trying to find a way around URL-rewriting for my new site. It's going to be a fully AJAX-based site where the URL has no importance in 90 % of the URL's.
After pressing F12 in Chrome and going to Network, I started monitoring the responsiveness as I changed the parameters in .htaccess.
I found that when entering an address that the server hadn't seen since restart, it spent 80-100ms to process the request (wait time). This is running on the localhost. This occured both when changing the dynamic part of the GET-request ?id=changeThis and when entering new URLs like /id/changeThis.. The next time however, it takes 8-12ms to process...
If I use ^(.*)
to redirect all requests to index.php didn't have an impact.
Question: Would it in a bigger scale matter if I use ^([a-zA-Z\-/]*)
(notice no period) to make static files like main.css not be rewritten, or is it best to put all files in a static folder (and thus loose flexibility) and still use ^(.*)
to redirect all requests not in the static exception folder. (I'm thinking speed here.)
Question: Can anyone approve my findings? Does Apache really 'cache' the requests, so that the first request to a specific URL will take time to process?
Upvotes: 1
Views: 1351
Reputation: 10464
To answer your questions:
Processing will be faster with less clauses, and a simpler regex - but we are talking on the order of a couple ms.
Apache does not cache requests in the way you are thinking - however, your linux system may be caching files, so subsequent loads are faster. I would think this is what you are seeing/thinking - both apache and website files are cached in the OS in pages for faster access. A restart should make these pages dirty and need a reload of them.
Upvotes: 1
Reputation: 3876
Disable mod_cache from the Apache configuration. In my configuration it was enabled by default.
Upvotes: 1