我正在使用一个静态类来包装Yahoo YUI compressor:

public static class Minifier
{
    private static readonly ICompressor javaScriptCompressor =
                                                   new JavaScriptCompressor()
    {
        CompressionType = CompressionType.Standard,
        IgnoreEval = true,
        ObfuscateJavascript = true,
        PreserveAllSemicolons = true
    };

    private static readonly ICompressor cssCompressor = new CssCompressor()
    {
        CompressionType = CompressionType.Standard,
        RemoveComments = true
    };

    public static string GetCompressedCss(string data)
    {
        //aaaand... action
        return cssCompressor.Compress(data);
    }
}

我想知道压缩机类是否是线程保存的?

最佳答案

JavaScriptCompressor不是线程安全的,应在使用后重新创建(它存储状态)。 CssCompressor不存储状态。

10-08 18:50