Bunch of performance fixes (PR #13246)

The query is being executed each time we try and generate the link path for a stylesheet within the duration of a reqeust. Categories are not updated that often so repeating this query multiple times a request is wasteful.

At the time of this commit, there is a publish_discourse_stylesheet ActiveRecord callback on the Category model which clears the cache of Stylesheet::Manager each time a category is saved.

GitHub

The title of this pull request changed from “PERF: Cache categories query in Stylesheet::Manager.color_scheme_digest.” to "Bunch of performance fixes