When 4D sends an HTML page that contains pictures, new connections will be made by the web browser to request these images.
In this case, the On Web Authentication database method will be run. In order to optimize execution you can parse the URL, detect if it's a request for a picture and immediately return True if it is.
This behavior can also be seen with recursive 4DSCRIPT tags. For this case, you can use a process variable as a flag to avoid redundantly executing the On Web Authentication and On Web Connection database methods.