What is given:
- nginx version: nginx/1.9.3;
- /var/www/site/js/site.chrome.js - code specific for chrome;
- /var/www/site/js/site.firefox.js - code specific for firefox;
- site.chrome.js and site.firefox.js are selected on the browser side depending on which browser runs the code;
- UA: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36
The problem: Instead of specifying in the browser which if the two JS files are to be loaded I would like to offload this task to the nginx server so that
- the browser just points to an URL like http://server.com/js/site.js
- the nginx parsers the UA, extracts OS, browser name, and its version and looks for the site.js in the following directory structure:
js | +-site.js | +-linux | +-chrome | | | +-site.js | | | +-44 | | | | | +-site.js
The js/site.js should be considered a fallback which means that if the nginx fail to find an appropriate site.js down the tree it uses the js/site.js file.
Given the aforementioned UA the nginx should look for the site.js in the following steps:
- js/linux/chrome/44/site.js
- js/linux/chrome/site.js
- js/linux/site.js
- js/site.js
The questions are:
- Does this way of organizing browser specific files in the directory tree at all has any sense, and if so...
- Can this approach be implemented with the nginx server;
0 Answers