Search code examples
phpimageanalyticstracking

Tracking image views - PHP


I'd like for my app to be able to tell if an image hasn't been viewed in the last 30 days and remove it (along with data in the DB associated with it). I know you can have PHP read and output the image dynamically but I've heard its quite taxing on the system. Is there a way to for me to track these hits even when the image is viewed directly? (would htaccess be able to do this?) Thanks in advance.


Solution

  • You can parse out the HTTP logs and do this analysis post-factum.

    That said, I'd still recommend going with a "dynamic PHP file outputting an image" approach - note that the PHP file can simply stream out a file. Yes, it'll be slower than not going through PHP at all, but it won't be a significant performance hit on your system.