Windows Apache IIS Deployment – Create Pre-Compressed Brotli Files

apache-2.4compressiondeploymentiiswindows

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.

Best Answer

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.

Related Topic