Dynamic web application hitting database on front page load to fetch profile image

  softwareengineering

Folks, I am in middle of writing a web application (Python/Flask) where home page has user profile image in the navbar which is coming from a database (blob), I am wondering if this is a good practice. Here I have following choices:

  1. Currently it is stored image in the backend db in a table in a blob
    field.
  2. Store the image disk location in the table instead of storing the image itself in the blob field, this will refer to the disk file
    where to load the image from instead of transferring the image file
    from a blob field.
  3. Avoid hitting the db altogether when accessing the images and use a local disk file location instead, this location can be mapped to
    nginx directly which means web caching will ensure fast image
    retrieval.

Wondering if this is a big issue and how you guys are handing it anyway, what is the industry best practices here? Please note the database will be hit anyway to load various other items like user first_name and possibly other bits too but I don’t want to lose the choice of storing images which can be cached.

Any help here will be highly apprecaited.

New contributor

afsar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT