This is no doubt a no but has anyone has experienced reading and redirecting the request in apache based on a config rule?
EG:
#Read /files/cache/static/xyz.cache and redirect to url in contents
I need to be able to read the contents of a file and redirect to the url specified.
This would allow apache to deal with a dynamic image request instead of it going through PHP.
I'm already doing something similar with HTML pages and it works beautifully but images I want to avoid having a "cached" copy of the image and would like to redirect to the actual file without involving an additional parser.
EDIT for clarity:
User 1 visits example.com/username-128-128.jpg
PHP then parses the url and retrieves the image at the right size and scale (either generating it or retrieving from file storage)
say the actual image is /var/www/files/images/username/128/128/image.jpg
PHP creates a file name "username-128-128.jpg.cache" file in /var/www/files/cache/static which contains "example.com/files/images/username/128/128/image.jpg" and then redirects to the actual file
Header("Location: example.com/files/images/username/128/128/image.jpg");
User 2: Requests the same file example.com/username-128-128.jpg
Apache see's there is a file "/var/www/files/cache/static/username-128-128.jpg.cache" it then reads that file and uses mod_rewrite to redirect to the contents of the file.
What i'm trying to avoid is creating a copy of /var/www/files/images/username/128/128/image.jpg
in
/var/www/files/cache/static/
Because it's wasteful.
Thanks
No comments:
Post a Comment