Extension, Plugin

Archived
Forum
(read-only)

Minimee

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From John D. Wells

     

Template Caching breaks Minimee

Support Request

PaleoSun
PaleoSun

Hi there,
  I just posted this issue on StackExchange, but I will copy it here:
http://expressionengine.stackexchange.com/questions/14268/template-caching-breaks-minimee

———————————
I am using Minimee 2.1.9 to combine and minify my css and js scripts on my EE 2.6.1 site. All works wonderfully if I don’t have Template Caching turned on. When I turn on template caching for a particular template, the page will load the first time, but after that, the minimee tags just return something like this “{f4acc930e16260a7c8fcfd443f232ba1fb6b238e}” instead of the minified/crunched or tag.

My issue seems similar to what’s happening with this thread

But I’m not using ‘Stash’.

Any idea how I can get around this, so I can use template caching?

Also, my {minimee} tags are within some Low Variables snippets, but I don’t think that’s related, as I’ve done a test where I bypassed low variables and got the same issue.

THANKS!

John D Wells
# 1
Developer
John D Wells

Hi PaleoSun,

Thanks for posting this here, as I don’t follow the SE threads on a regular basis.  Hopefully we can get to the bottom of your issue with ease.

Are you using Minimee’s Queue method for minifying your files? Would you mind pasting in a snippet of how Minimee is being used in your template?

Cheers,
John

PaleoSun
# 2
PaleoSun

Hi, John. Thanks for your reply.

Yes, I am using the queue method. Here is the minimee code outputting my css:

{exp:minimee:css queue="head_css"}
 
<link rel="stylesheet" type="text/css" href="/css/normalize.css" />
 <
link rel="stylesheet" type="text/css" href="/css/bjqs.css" /><!--basic slider css-->
 <
link rel="stylesheet" type="text/css" href="/usernoise/css/button.css" />
 <
link rel="stylesheet" type="text/css" href="/css/style.css" />
 <
link rel="stylesheet" type="text/css" href="/css/wygwam-style.css" />
{/exp:minimee:css}

{exp
:minimee:display css="head_css"

And here’s the code outputting my js:

{exp:minimee:js queue="foot_js" priority="-1"}
  [removed][removed]
 {
/exp:minimee:js}
 {exp
:minimee:js queue="foot_js"}
  [removed][removed]
  [removed][removed]
  [removed][removed]
 {
/exp:minimee:js}

 {exp
:minimee:js queue="foot_js" priority="10"}
  [removed][removed]
  [removed][removed]
 {
/exp:minimee:js}

 {exp
:minimee:display js="foot_js"

As a sidenote, someone on the SE thread suggested adding the ‘random’ keyword to my minimee tags, and I tried that to no avail. Not quite sure if I got the syntax right for that though…

PaleoSun
# 3
PaleoSun

And in case this helps as well, here is my minimee config:

// Minimee Config - http://johndwells.github.com/Minimee/
$config['minimee'= array(
 
'cache_path'  => 'cssjs-cache',
 
'cache_url'   => $base_url.'/cssjs-cache',
 
'combine_css'  => 'yes',
 
'combine_js'  => 'yes',
 
'minify_css'  => 'yes',
 
'minify_html'  => 'no',
 
'minify_js'   => 'yes',
 
'disable'   => 'no',
 
'cachebust'   => '',
 
'cleanup'   => 'yes',
 
'css_library'  => 'minify',
 
'css_prepend_mode' => 'yes',
 
'css_prepend_url' => $base_url,
 
'hash_method'  => 'sha1',
 
'js_library'  => 'jsmin',
 
'remote_mode'  => 'auto'
); 
John D Wells
# 4
Developer
John D Wells

Hi PaleoSun,

The random tag parameter isn’t relevant here, because it’s a slightly different issue to the one that is meant to resolve…

At least in the short-term, there is no real fix other than to disable caching of any template that contains Minimee queue or display tags. It turns out this is pretty much a requirement for the Queue method to work correctly.  I’ll try to explain why:

With Queuing, Minimee’s template tags are initially parsed during the normal stages in EE’s parse order.  Yet instead of processing and creating the cache, it waits to see if any other queue tags are run, each time saving what it finds in the session.  When it encounters the “display” tag, it replaces it with a placeholder string (that “{f4acc930e16260a7c8fcfd443f232ba1fb6b238e}” thing).

Once all template processing is done, by hooking into the “template_post_parse” hook, Minimee then processes all of the tags it found during runtime, compile the results, and then replaces the placeholder string with the final result.

The way EE template caching works, it caches the result of normal tag parsing, but *before* the template_post_parse hook.  That’s why the placeholder string is still there in the template, and why on subsequent runs even though the template_post_parse hook runs, Minimee won’t have any saved tags to process.

I hope that makes some sense.

If you were to ever use CE Cache, it has tags that allow you to escape it’s caching, so Minimee can still work very well alongside that, even the queue method (as long as all of Minimee’s tags are escaped).

I will make a note in Minimee’s docs as to the caveat with the Queue method, and I’m sorry for the inconvenience.

Cheers,
John