大网数据广告活动
服务器运维问答

Ways to make deployment ready pre-compressed brotli files on windows server

· 52CE 我爱测

I am dynamically generating HTML files, which I use for deployment. This is what I use to make these HTML file: function writeFile() Dim objStream Set objStream = CreateObject("ADODB.Stream") objStream.CharSet = "utf-8" objStream…

问题原文

原帖链接 · MeSo2 · CC BY-SA 4.0

I am dynamically generating HTML files, which I use for deployment.

This is what I use to make these HTML file:

function writeFile()
    Dim objStream
    Set objStream = CreateObject("ADODB.Stream")
    objStream.CharSet = "utf-8"
    objStream.Open
    objStream.WriteText content
    objStream.SaveToFile absoluteFileLocationAndName, 2
    Set objStream = Nothing
end function

What are my options to obtain, in addition, a pre-compressed version?

I am not sure if I need to go as far as implementing https://github.com/AnderssonPeter/CompressedStaticFiles ... but it would bring the benefit of adding CSS, and JS file compression. Side Note: for CSS and JS compression I plan on using Notepad++ run program on save to automatically minify and then compress minified file.

Similar post Tool to create pre-compressed [Brotli] files

As an alternative I found PeaZip which allows brotli compression on files, but would need to find a way to integrate that.

I am using MirrorFolder Cloud Edition to deploy my files, FTP synchronized in real-time. MirrorFolder allows for pre- and post commands to be run during execute. I suppose at that point I could have PeaZip run a script to create a pre-compressed brotli version of the file.

Thank you for your suggestions and ideas on any other tools I could use to do this.

已采纳解答

原帖链接 · MeSo2 · CC BY-SA 4.0

I was able to use PeaZip to make pre-compresses Brotli files:

function make_Brotli_version(absoluteFileLocationAndName)
    dim command, shell
    command = "%comspec% /c " & _
        " ""C:\Program Files\PeaZip\res\bin\brotli\brotli.exe"" -9 " & _
        absoluteFileLocationAndName & " -o " & absoluteFileLocationAndName & ".br"
    Set shell = Server.CreateObject("WScript.Shell")
    shell.exec command
    set shell = nothing
end function

Here (trying to be helpfull) I am going to expand a bit outside of the scope of my question ... because if you are after this answer, you maybe also after how I got to minify my HTML files.

A Free HTML delinting on Windows 10 can be a challenging undertaking.

I discovered https://github.com/kangax/html-minifier and it is working nicely. Being on a Window OS, it was a bit tricky to get it all working, here a link to my post https://github.com/kangax/html-minifier/issues/1143 as I was working things out. Nonetheless, all is good! The way I got the callback to work is to code around it; by verifying if the file has a newer DateCreated (or DateLastAccessed) using asp. (To minify JS files I ended up using google-closure-compiler.)

And for CSS, JS, and HTML files, I now have my Notepad++ delinter set up, so with a save it automatically makes these additional files.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-07-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。