I wrote a caching class. It automatically gets the page content after many database queries and saves it as a .html file. Every 600 seconds, it reads from this .html page instead of querying.

To improve reading speed even faster, I want to remove unwanted characters like " " (space) \n\l and such. How can I do this?

I know I can do this in many ways. trim, str\_replace and so on. I want to know the fastest - and the safest (so it won't break javascript) way to rely on. :)

Thank you.