I am developing a phonegap app, one part of the app is about 10 images that are base64 encoded and downloaded about once per week per user(100 users now, hopefully growing alot)
My server is slow, which i am also working on, so delivery of these images is slow.
My question is:
Would it be faster, php and server wise, to generate and save these base64 images to a db once and fetch the images from the db on request OR base64 encode the image every time the image is requested?
Thanks for your help.
It would definitely be faster to base64 encode the images and store the encoding.
This is a classic memory vs. speed tradeoff, you can pay a lower computation cost, for a higher memory cost. In this case, that means storing more data (
8/78/6 more if you just keep the encoded version, and a little more than 2x if you keep the original too).The best thing you could do is keep the images in memory, since this would avoid the cost of accessing the disk. You can do this with shared memory functions, or by abusing the session variables and assigning a fixed session id to retrieve content.