ExpressionEngine icon indicating copy to clipboard operation
ExpressionEngine copied to clipboard

On eemcs and CDNs

Open robsonsobral opened this issue 3 years ago • 5 comments

I had some discussion with a coworker about the throttling module. Today, it's something for an emergency only, because this kind of feature is something we manage at a different level of a site: in the front of the server. This also point to other anachronistic serving related things eecms has:

Manipulated images always have the same name

The manipulated image files have the same name as the original filename, but on manipulation specific folders. Any modification can cause a cascade of stale content over the network. We could have partial MD5 hashes added to them to avoid that kind of issue.

Assets management and cache busting

Doug Black wrote an great article about how to use Laravel Mix to compile assets, but, due to Mix own difficult to handle cache busting, the URLs are suffixed using a query string, which isn't enough for CDNs.

We are lucky! EECMS already has the solution for that: the {stylesheet="group/template} path tag! I'm going back to eecms after years of JS projects and I never imagined I would use {stylesheet} again. However, the build process become so complex that any help are welcomed. Over the time, I used Gulp, Parcel, webpack, pure NPM scripts and more tools than I can remember now. We can use Laravel Mix or whatever to compile/build the assets and just dump the final files at a "template.group" folder.

Could we have a {script="group/template"} path tag? Then, we could add the hash suffix to that!

Search by POST and non cacheable URLs

Now, the part that I think it is the harder to improve: the search results templates.

  • they aren't sharable;
  • they aren't cacheable;

To fix that, the {exp:search:search_results} tag needs to be able to use parameters from URL. Using GET, the query string parameters also need to be alphabetically sorted, to make sure the full URL is always the same.

There's a legend that changes are being made to the search form. I'm curious to see them!

robsonsobral avatar Jul 28 '21 00:07 robsonsobral

Re Assets management and cache busting

Adding a {script} tag to mirror the {stylesheet} tag is understandable: the {stylesheet} tag primarily offers a route to avoid template parsing of the content of the stylesheet and so some performance gain when serving the file from within EE, and I guess a similar benefit could be obtained for javascript files.

However in your block quote comment you focus on the description in the documentation of an option to explicitly run the stylesheet through the parsing process - which is fine if this is helpful - but the solution offered (to link to the file concerned using the {path=} global template variable) is one that could equally well be applied to javascript files too. Which suggests the benefit you are seeking is already provided...?

I am guessing I'm missing something in this... hence request for clarification.

jcogs-design avatar Jul 28 '21 11:07 jcogs-design

@jcogs-design , I'm sorry! I wrote on my code editor, pasted here and edited again. I'm under the stress of a huge project right now.

I removed the nonsense part. I'm sorry. And thank you for pointing me to the confusing part.

robsonsobral avatar Jul 28 '21 18:07 robsonsobral

(See #1230 for how to make CDN content trustful.)

robsonsobral avatar Jul 30 '21 15:07 robsonsobral

@robsonsobral now that we have merged #1259, should we consider this as done and close the issue?

intoeetive avatar Aug 31 '22 13:08 intoeetive

Per topic:

Manipulated images always have the same name

I've no idea. I haven't tested eecms 7 yet.

Assets management and cache busting

Yes! It's done!

Search by POST and non cacheable URLs

I don't know. I haven't tested the Search Pro module.

robsonsobral avatar Aug 31 '22 14:08 robsonsobral