Title: Cache busting stopped working
Last modified: September 13, 2021

---

# Cache busting stopped working

 *  Resolved [ceap80](https://wordpress.org/support/users/ceap80/)
 * (@ceap80)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/)
 * In the latest update cache busting is broken.
 * Function *_build_single_hash_url* says:
 * // $qs_hash is from src, same as $filename, redundant
 * but it’s not redundant as $filename has the query string part removed, so no 
   matter if I change the query string it will generate the same hash thus breaking
   the cache burst functionality.

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14868381)
 * Hi,
 * what is exactly are you referring to as `cache burst` ?
 * Best regards,
 *  Thread Starter [ceap80](https://wordpress.org/support/users/ceap80/)
 * (@ceap80)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14868405)
 * Hi, let’s say I have this in the head section of my template
 * `<link rel="stylesheet" type="text/css" href="<?php bloginfo('url') ?>/app/assets/
   css/common.css?version=30" />`
 * before the latest change changing the version parameter to something like `version
   =31` instructed the plugin to generate a new filename.
 * With the latest change no matter what value the version parameter has, the plugin
   will generate the same file name as is ignoring the query string completely.
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14868425)
 * Hi,
 * it is generated based on file content’s md5sum value
 * and why would you want to change/update/regenerate if the file content is same?
 * Best regards,
 *  Thread Starter [ceap80](https://wordpress.org/support/users/ceap80/)
 * (@ceap80)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14868489)
 * > it is generated based on file content’s md5sum value
 * That seems to be the case when the plugin is combining the files but if the plugin
   is only doing file minification it ends up hitting `_build_single_hash_url` function
 *     ```
       /**
        * Build a single URL mapped filename (This will not save in DB)
        * @since  4.0
        */
       private function _build_single_hash_url( $src, $file_type = 'css' ) {
       	$content = $this->__optimizer->load_file( $src, $file_type );
   
       	$is_min = $this->__optimizer->is_min( $src );
   
       	$content = $this->__optimizer->optm_snippet( $content, $file_type, ! $is_min, $src );
   
       	// Save to file
       	$filename = $file_type . '/' . md5( $this->remove_query_strings( $src ) ) . '.' . $file_type;
       	$static_file = LITESPEED_STATIC_DIR . '/' . $filename;
       	File::save( $static_file, $content, true );
   
       	// $qs_hash = substr( md5( $src ), -5 );
       	// return LITESPEED_STATIC_URL . "/$filename?ver=$qs_hash";
       	// $qs_hash is from src, same as $filename, redundant
       	return LITESPEED_STATIC_URL . "/$filename";
       }
       ```
   
 * Here it seems the md5 is being generated based on the file url and not on the
   file content
    -  This reply was modified 4 years, 9 months ago by [ceap80](https://wordpress.org/support/users/ceap80/).
    -  This reply was modified 4 years, 9 months ago by [ceap80](https://wordpress.org/support/users/ceap80/).
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14876538)
 * yes but for minify , as you can see
 * `md5( $this->remove_query_strings( $src ) )`
 * md5sum value based file name with query string removed
 * so you have file like `test.css?version=1` , it will be used like `test.css` 
   only
 *  Thread Starter [ceap80](https://wordpress.org/support/users/ceap80/)
 * (@ceap80)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14876569)
 * And that is precisely the issue, if I make a change to the file the name generated
   by the plugin will stay the same. So if I use a very long cache time for the 
   assets the browser will not pick up the changes. The solution here is to use 
   the content for the md5 thus changing the generated file name automatically or
   at least not ignoring the query string so I can change it when I make some changes
   to the file. Just like it was working in the 4.3 version.
 * I’ll copy here for reference, the function from the version 4.3
 *     ```
       /**
        * Build a single URL mapped filename (This will not save in DB)
        * @since  4.0
        */
       private function _build_single_hash_url( $src, $file_type = 'css' ) {
       	$content = $this->__optimizer->load_file( $src, $file_type );
   
       	$is_min = $this->__optimizer->is_min( $src );
   
       	$content = $this->__optimizer->optm_snippet( $content, $file_type, ! $is_min, $src );
   
       	// Save to file
       	$filename = $file_type . '/' . md5( $this->remove_query_strings( $src ) ) . '.' . $file_type;
       	$static_file = LITESPEED_STATIC_DIR . '/' . $filename;
       	File::save( $static_file, $content, true );
   
       	$qs_hash = substr( md5( $src ), -5 );
       	return LITESPEED_STATIC_URL . "/$filename?ver=$qs_hash";
       }
       ```
   
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14876573)
 * thanks, I will pass the case to our devs
 *  Plugin Support [Hai Zheng⚡](https://wordpress.org/support/users/hailite/)
 * (@hailite)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14878860)
 * Thanks for the good catch. This is fixed in v4.4.1-a3.
 *  Thread Starter [ceap80](https://wordpress.org/support/users/ceap80/)
 * (@ceap80)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14891317)
 * Your welcome! And thanks for the quick response.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Cache busting stopped working’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)

 * 9 replies
 * 3 participants
 * Last reply from: [ceap80](https://wordpress.org/support/users/ceap80/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/cache-busting-stopped-working/#post-14891317)
 * Status: resolved