teamcfadvance / cfstatic

CfStatic is a framework for managing the inclusion and packaging of CSS and JavaScript in CFML applications.
https://teamcfadvance.github.io/cfstatic
MIT License
102 stars 35 forks source link

clashing hash on two CSS/JS packages with the same name on second load when checkForUpdates=true #117

Open chopki opened 2 years ago

chopki commented 2 years ago

preface - looking for a fix and will pop a pull request if i can nail down whats going on, but thought best to post in case anyone else had come across or had a better working knowledge of cfstatic and could pin it down quicker.

Issue - I have two directories assets\css\core and assets\js\core that both contain lots of files that are set to minify & concatenate down to one file that has been working like a dream forever. Since upgrading to CF 2021 (seems compatible otherwise) it seems on the first load of the application everything works fine, but on the second page load the hash for the JS file gets set to the same as the hash for the CSS file.

e.g output initial load ( hashes 20220826055440 & 20220831091516 )

<link rel="stylesheet" href="https://[domain]/assets/static/core.min.20220826055440.css" media="all" charset="utf-8">
<script type="text/javascript" src="https://[domain]/assets/static/core.min.20220831091516.js" charset="utf-8"></script>

second load ( single hash 20220826055440 )

<link rel="stylesheet" href="https://[domain]/assets/static/core.min.20220826055440.css" media="all" charset="utf-8">
<script type="text/javascript" src="https://[domain]/assets/static/core.min.20220826055440.js" charset="utf-8"></script>

This only seems to happen on the development and staging environments where we set the checkForUpdates parameter to true

initialisation:

<cfset application.cfstatic = new shared.lib.cfstatic.CfStatic(
    staticDirectory     = application.root_path & "assets",
    staticUrl           = application.basehref & "/assets",
    outputDirectory     = "static",
    includeAllByDefault = false,
    forceCompilation    = true,
    checkForUpdates     = application.cfstatic_check_for_update,
    debugAllowed        = true,
    debugKey            = key,
    debugPassword       = pass
)>

Other setup details - Windows / CF 2021 Enterprise

seybsen commented 2 years ago

I diffed https://github.com/teamcfadvance/cfstatic/blob/master/org/cfstatic/CfStatic.cfc with our copy of the file. The only thing we changed for CF2021 was this line:

https://github.com/teamcfadvance/cfstatic/blob/master/org/cfstatic/CfStatic.cfc#L211

our timeout is set to 100 instead of 1, but unfortunately I don't really know why this change was made. Could have been because of the same error you are experiencing.