Based on an answer I saw in this question: Link
I’m wondering, is this a safe thing to do?
Suppose I implement this and a page gets requested that has a couple of JS and CSS files linked to it. Are the textfiles simply sent or does the server first parse them? Don’t have a server to test it right now.
Also, is this a common method of working? I’m thinking that setting up your files so you always get the correct implementation based on user input can be pretty hard when it comes to CSS and JavaScript.
For dynamic CSS and Javascript you dont’ always have to have them in .js or .css files. What you can do there is actually link to a PHP script that generates them so that all other .js and .css files that aren’t dynamic aren’t parsed by PHP. Generally it is a bad idea to run everything, especially media files, through an app server/dynamic parsing unless absolutely necessary (same goes for .net, RoR, Django etc).
browser treats the same as:
You can also take dynamic js or css and push it through rewrite so it does have the correct extension but it is actually a php file that is dynamic as well if you don’t want your links and script tags to have incorrect extensions.