web services - Architecture for high performance caching of image files created on the fly -


i'm developing application needs serve raster image files @ varying zoom levels of vector image stored on server. imagine having vectorized data of streets , buildings, , generating on fly png tile google-maps-like service, response client's request zoom level , coordinates.

in case underlying vector data changes quite plus zoom levels @ closer increments e.g. dozen or fixed zoom steps in google maps. hence, me impractical pre-calculate possible tiles , upload them high-performance static media server.

is there elegant way first request specific tile served app generates , subsequent requests served static media server?

assume generate tile on app server can instantly make available on static media server.

the obvious approach use redirection if tile has been generated sub-optimal, (a) load app server many unnecessary hits , (b) reduce overall performance client browser need send 2 requests in series before getting image data, approximately doubling response time.

so i'm looking other ideas. e.g. there way configure web server try , use high performance static file serving , if file doesn't exist fall calling app instead of returning 404?

this relatively common problem generate file cache if not exist, can served directly webserver.

in nginx, there try_files option. takes set of uris and, expect, tries each 1 till finds response. if first set fails, later 1 returns ok , data (and while it's there, creates file match first try-file path) next request short-circuited.

try_files $uri $uri/ /makecachefile.php?q=$uri&$args; 

in apache, perform same mod_rewrite

rewriteengine on rewritecond %{request_filename} !-f rewriterule ^(.+)$ /makecachefile.php?q=$1 [l,qsa] 

here, check if particular file served request, , if not, pass url script may go on generate it.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -