I am working on a web-application in which dynamically-created images are used to display information. This data is currently sent to the images using a GET query-string but with more complex images and data I am worried about running into problems with the url character limit.
I could simply pass the record ID to the image and have this query the database but this would obviously increase demand on the server. Is there some way I could add an image retrieved using POST into a HTML document?
In the end, I think quering the database will probably be faster. To get a small string (say up to 2000 characters) from the database is very quick and probably faster than having the user post it all the time, especially if there is more than 1 on a page.
The best option would be create the image once and cache it if it doesn’t change. When the image is requested again, check to see if it’s cached and just use readfile() to send it to the browser. I like to store the cached image outside the doc root so it’s not accessible by others, but this may not be a factor in what you’re doing (both caching and privacy).
The SESSION might be an option, but this is the best option when you need to regenerate the image on multiple pages with slight changes, so you don’t have query the db each time.