0

Right now I am providing an interface on my website to allow users to upload 3 image files. This number may increase in future.

The image filenames are being stored in the database for example

  Image1  |  Image2  | Image3

cat.jpeg  |  dog.jpeg |  mouse.jpeg

My PHP script then retrieves these filenames from the DB then downloads them to the client machine

  1. It takes 2s for Jquery to download (0s cached)
  2. 400ms for PHP script to pull data including the image names
  3. 2s for the image to download

About 2.4seconds total time to download when cached. Is it possible to speed up this process? Could I store the images on the server named as 1.jpeg, 2.png etc and remove the reference on the DB? Is it best practice to compress images on the server and if so how?

Mukesh Ram
  • 6,248
  • 4
  • 19
  • 37
user2202098
  • 830
  • 1
  • 9
  • 24
  • 2
    db normalisation would be a great start –  Jul 17 '16 at 22:04
  • take a look at this tutorial; http://forum.codecall.net/topic/40286-tutorial-storing-images-in-mysql-with-php/ you need to store images as blob in mysql – unixmiah Jul 18 '16 at 05:49
  • @unixmiah this post says to stay away from using the db http://stackoverflow.com/questions/348363/what-is-the-best-practice-for-storing-uploaded-images – user2202098 Jul 18 '16 at 11:49
  • @user2202098 storing file on a filesystem is faster. storing assets in the database is ram intensive. – unixmiah Jul 19 '16 at 22:51

0 Answers0