0

On using any combining plugin for CSS and JS files they "lose" their correct MIME type - because combining plugins do their job by PHP.

So the result of this job, file alike http://www.example.com/assets/style.css?combined=20180202 aren't recognized as CSS, but as PHP, and my cache settings for CSS files don't work for them.

Same game with JS: files like http://www.example.com/assets/script.js?combined=20180202 aren't recognized as JS, but as PHP and cache settings for JS don'r work for such combined files.

What can i do to correctly cache combined files?

  • Do you send the MIME type header? Did you think about leaving the query parameter and maybe use it in the filename (I think files with query param aren't cached by default?) – kero Feb 2 '18 at 14:09
  • All the plugins I've used combine the CSS & JS into actual files in the filesystem. These will almost certainly have the correct type. Virtual files that don't actually exist, but are dynamically created in PHP on request might not, but only if the developer neglected to send the correct headers. Dynamically generating the combined file on every request though probably wouldn't help performance, and might even hurt it, so it would not be the best method to do this. – Jacob Peattie Feb 2 '18 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.