Question

I have build a simple MVC library. There is a front controller. htaccess file sends all requests to front controller except images, js, and css. But I have a problem which is I want to build JS and CSS files with PHP. (Not every time though some times.)

For this purpose, I am planning to send CSS and JS file requests to front controller, and from there, another PHP will "include" corresponding CSS or JS file, and return it back to client. When CSS or JS is included, it will be processed by PHP interpreter as well.

Though what makes me think is performance. I am only doing development at the moment, and I am not able to see how the system will respond this kind of technique when thousands of request comes. Since when you build a big system, it is hard to change immediately. So I want to build this features into MVC in early stages.

If anyone tried a technique like this, I would like to hear performance measurements.

Was it helpful?

Solution

Performance in this case is a minor issue.

What you have to understand is that, in production stage the CSS and JS files will be generate with far-future expire headers. Thus, each visitor will request this resource only once, and in every subsequent page-view use files from browser-cache.

And, if generation process is complicated, you can always cache the current version of those resources, which would cut down the response time even more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top