Skip to content

Performance issue by supported_directives method #187

@igrep

Description

@igrep

Problem

The change in #179 can cause a performance issue.

I learned that lib/secure_headers/headers/content_security_policy.rb,
UserAgentParser.parse(@ua) in supported_directives is executed for each request.
As user_agent_parser's author is planning to remove, UserAgentParser.parse(@ua) is problematic.
Because it loads common regexps yaml file as large as 4.7k lines on every call.

Possible solution

According to user_agent_parser's README's recommendation, we should instantiate a user_agent_parser by UserAgentParser::Parser.new, then cache it.
So, which class / object should cache a user_agent_parser?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions