php - What's an easy way to detect a file has changed and update it automatically? -


what's easy way detect file has changed , update automatically?

for example if have js/css file uploaded, i'd server detect uploaded new js/css files , minify them automatically right , there.

edit: i've tried minifying @ run time , found out it's not efficient. it's interesting note, file minified requesting file overhead in , faster not minify file delivery.

ideally, file should minified within few seconds of upload. instead of polling system, there event based system out there into?

edit: used mikhailov answer , added following incron file:

/var/www/laravel/public/js/main.js in_modify yui-compressor -o /var/www/laravel/public/js/main.min.js /var/www/laravel/public/js/main.js  

inotify recommended pattern notified re file system events (file created, modified or deleted), wikipedia says:

inotify (inode notify) linux kernel subsystem acts extend filesystems notice changes filesystem, , report changes applications.

see similar use case: how notified of files being copied on rsync.


Comments