PHP and JS CacheHandler path differences
As I am finishing the Wigbi 1.0 implementation, the time has come to implement the JS versions of the Wigbi PHP handler classes. As I implemented the CacheHandler JS class, I came across an interesting problem.
In this post, ~/ indicates the application root, which is where the wigbi folder is located.
In PHP, the CacheHandler class uses page relative paths to the cache folder. All class functions are executed directly when called, which makes page relative paths natural.
In JavaScript, however, the same does not apply. Since the JS class uses asynchronous methods, a page that calls a method will not exist in the same folder as the one that executes it.
This leaves us with an interesting scenario. Say that the page ~/admin/account/myAccount.php sets the cache folder to ../cache.
With PHP the cached files will end up in ~/admin/cache/.
With JavaScript, however, the call is sent to ~/wigbi/pages/postBack.php, where it is executed. Thus, the ../cache path will make the cached cached files end up in ~/wigbi/cache/.
Using the same kind of paths for PHP and JavaScript will therefore not work. Instead, the JavaScript class is set to use application relative paths. Instead of ../cache, use admin/cache.
The CacheHandler JavaScript class will automatically adjust application relative paths so that the postback page can use them.
