Detects cache headers and runs the appropriate function.