Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
code share

HTML Comment Scrubber

Problem this snippet solves:
HTML Commenting is very useful for documenting your site content. Unfortunately, that information can sometimes be private and it is not a desired situation to let everyone viewing your website to be able to access those comments. This iRule will perform a regular expression search on the HTTP response content and if it finds a HTML comment in the form of "!(ws)...(ws)" (ws - whitespace), it will replace all the characters with a space. I could have removed the characters from the reponse, thus shortening the payload, but by keeping the size the same that reduces the need to configure your virtual server to rechunk responses.
How to use this snippet:
Keep in mind that this will remove any and all content in between "!--" and "--". That includes javascript code inside a script block. I'll leave it to you all out there to modify the regexp to account for non javascript commented code blocks...
Comments on this Snippet
Comment made 23-Jul-2015 by quantiti 123
Hello, what about something like this: <!--[if lt IE 9]> <link rel="stylesheet" href="/ipay/pages/common/styles/ie8.css;jsessionid=XkhBVxdbG5n1WGc2yhGc1lYv7fvdgHLh85fmnKCc2hbNyyPzM8rN!-998811227" type="text/css" /> <![endif]-->
0