Friday 15 June 2012

php - Creating a cache layer for images -


I am working on a PHP web application, in which I have to present the cash layer on my database.

To store images in a special cache layer taken from DB, the images are in large size: 4-8 MPs What would be the best way to do this?

Here's a suggestion for a plan:

Create three folders - thumbnails Display images and original images In these you will store cached versions of thumbnails, versions of web display versions and your original image.

When an image is uploaded, give it a unique name in your file system and store it there.

Assume that you have some kind of browser to select from these images ...

Retrieve image data from the database. Use it to detect thumbnails, display versions or origins.

When an image is browsed, look for an existing thumbnail if you have one, then send it. If you do not do this, then create it, store it in your thumbnail folder, and send it.

When a browser grows for display in the browser, check for the display version and more. For thumbnails

When an image is selected to download, send the original.

You use a size version to be displayed after 4-8 MP. All of this needs to be cautious with cash-control - PHP output will not be automatically cached, so you need to add the header yourself, doing this correctly can speed up your application.

You can play with it to add sub folders, if it is appropriate, adjust the size of your cached resized images etc.

Good luck!

No comments:

Post a Comment