wrapped the purge cache functionality into a function
restructured the code a little and now also returning an alert response message in the front-end instead of printing it in the HTML