Jump to content
thirty bees forum

Question

Posted (edited)

Hello, I need clarifications regarding the media servers functionality and CCC

Media servers are said to be used only with CCC enabled but it is very confusing to me: which of the many toggles of CCC are required for using media servers?

Smart cache for CSS and JS is handled by mrclay/minify. This script supposedly minifies and combines CSS and JS files into a single CSS and single JS, the problem is that this is a very outdated script which does not support modern JS and also breaks my CSS.

I want to minify and combine CSS and JS on my own (with csso and terser, actively maintained scripts) and provide these files to my CDN (media servers). Why is this not possible?

Edited by Jeffrey de Bruijn

7 answers to this question

Recommended Posts

  • 0
Posted
3 hours ago, Jeffrey de Bruijn said:

Hello, I need clarifications regarding the media servers functionality and CCC

Media servers are said to be used only with CCC enabled but it is very confusing to me: which of the many toggles of CCC are required for using media servers?

Smart cache for CSS and JS is handled by mrclay/minify. This script supposedly minifies and combines CSS and JS files into a single CSS and single JS, the problem is that this is a very outdated script which does not support modern JS and also breaks my CSS.

I want to minify and combine CSS and JS on my own (with csso and terser, actively maintained scripts) and provide these files to my CDN (media servers). Why is this not possible?

Hi,

And why not simply propose an evolution to use a different and more modern and powerful script in the Core of thirtybees?

  • 0
Posted (edited)
16 minutes ago, Mediacom87 said:

Hi,

And why not simply propose an evolution to use a different and more modern and powerful script in the Core of thirtybees?

That does not sound simple at all 🤣 I do not want to change and implement a new library, I am not good enough to do that and have people depend on my php skills.

In my opinion, just dropping the library might be better. No need to rely on third party libraries that may get abandoned and break, plus developers have their own preferences too. For example I work in LESS and CoffeeScript and I already compile these to CSS and JavaScript, minifying is built in my tooling, I do not need another tool to minify my code.

That said, I am still confused: does enabling media servers without CCC work? If so, what is handed to the CDN?

Edited by Jeffrey de Bruijn
  • 0
Posted

I think dropping it would be extremely short sighted. Just because its old and no longer actively developed does not mean there are bugs. If your CSS is breaking when it is enabled, the problem is likely your css and not terminating media queries correctly. 

 

The CCC does more than just combine and compress files a big function of what it does is bust caches. It busts them in a way that they can still be cached, unlike using query strings. Not every shop user is a developer writing their own CSS and wedging it into a theme, you are likely in the 1%. Also, your way of doing it is likely bad since I have to imagine that you are changing compiled names between updates. thirty bees has a setting to keep the old files, which makes it where you site will still load from the internet archive, google cache, and now with cloudflares new always online. 

As for enabling media servers with CCC on, why not test it? It takes just a couple seconds. It does not by default, you can write a small module or override to make it though, but it will make your life harder if you are using a real cdn. You will need to manually clear there unless you are compiling your css with a hashed file name. 

  • 0
Posted
2 minutes ago, lesley said:

As for enabling media servers with CCC on, why not test it? It takes just a couple seconds. It does not by default, you can write a small module or override to make it though, but it will make your life harder if you are using a real cdn. You will need to manually clear there unless you are compiling your css with a hashed file name. 

Because I do not have a CDN to try and I want to understand how it works beforehand.

A CDN is not strictly to serve stylesheets and js but for other static content like images and videos too. Why would thirty bees need to force js and css caching if users want to serve images and videos via a CDN?

8 minutes ago, lesley said:

I think dropping it would be extremely short sighted. Just because its old and no longer actively developed does not mean there are bugs. If your CSS is breaking when it is enabled, the problem is likely your css and not terminating media queries correctly. 

My CSS is fine, thank you very much. Dropping it may be a bad idea, but the repository has a load of issues open that are not being addressed. CSS and JS are constantly changing and if a library that manipulates this kind of code does not keep up, it is obviously going to have issues; look at how much work it is being done on actively maintained projects such as csso and terser just for minifying.

20 minutes ago, lesley said:

The CCC does more than just combine and compress files a big function of what it does is bust caches. It busts them in a way that they can still be cached, unlike using query strings.

That is a good point, thanks for making me notice that.

21 minutes ago, lesley said:

Not every shop user is a developer writing their own CSS and wedging it into a theme, you are likely in the 1%.

Who exactly develops themes if not developers? I'm sorry but even users who do not develop their own themes use themes somebody else develops for them. I do not understand what your point is with this statement.

24 minutes ago, lesley said:

Also, your way of doing it is likely bad since I have to imagine that you are changing compiled names between updates.

Wrong assumption, not doing that.

  • 0
Posted

The media servers work fine for other assets when you use them, they just do not cache css and javascript if CCC is not enabled. This provides you the ability to locally debug without bringing the CDN down for your whole site. 

If your CSS is having issues, I would run it through a validator, the only time I have ever seen the CCC library have issues is when people short close statements at the end of files. If you are using properly formed CSS and there is truly a bug, report it with an example, it will help it get fixed. 

 

Quote

Who exactly develops themes if not developers? I'm sorry but even users who do not develop their own themes use themes somebody else develops for them. I do not understand what your point is with this statement.

I don't think you follow. Its all an ease of use thing. It keeps the development flow where users can clear their cache and changes are shown. With what you are suggesting, users would have to load a minified file, try to find the code they want to change, change it, save it on the server, then go to their cdn and void the caches. That is not considered user friendly for novice users. I cannot think of any software package that ships with pre-minified code other than PrestaShop 1.7, and how is that working out for them?

  • 0
Posted (edited)
18 minutes ago, lesley said:

I don't think you follow. Its all an ease of use thing. It keeps the development flow where users can clear their cache and changes are shown. With what you are suggesting, users would have to load a minified file, try to find the code they want to change, change it, save it on the server, then go to their cdn and void the caches. That is not considered user friendly for novice users. I cannot think of any software package that ships with pre-minified code other than PrestaShop 1.7, and how is that working out for them?

I indeed do not follow. I only follow that yes, having to clear the CDN cache manually is not as immediate.

What do you mean with users having to load a minified file?

Users generally do not even touch CSS nor JS and their developers do it for them. The current situation with the default theme is even more complex as users are asked to compile the entire SASS directory to CSS. If a user is expected to be able to do that I imagine that they are also able to minify their CSS.

Edited by Jeffrey de Bruijn
  • 0
Posted
On 3/19/2022 at 1:06 PM, Jeffrey de Bruijn said:

Media servers are said to be used only with CCC enabled but it is very confusing to me: which of the many toggles of CCC are required for using media servers?

You can use media server even without CCC enabled

Anyway...

I have seen couple of issues with CCC, but it always boiled down to incorrect source/asset files. Not really problem with CCC algorithm, although it could definitely be improved to prevent (or at least report) these issues

For example, in css file the last rule might not be closed properly:

.rule-1 {
  font-size: 10px;
}

.rule-2 {
  font-size: 20px;
}

.rule-3 {
  color: black;
  // note that this rule is missing ending parenthesis

When this css file in used directly, browser will be lenient, and parse and use the first two rules, but ignore the third one. The page will be displayed somewhat properly (only one rule will not be applied, which might not be a big issue)

However, the situation will be much worse when this css is combined with other. The missing } at the end of file will break all rules from all css files that might be appended after this invalid css file. The situation will be even worse for javascript files.

In these cases, the input to CCC algorithm is invalid. Even if we used better / newer library, the result could not be valid -- no algorithm can 'fix' invalid inputs. 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...