Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: cached pages have different URL
Status | Resolved |
Add-on / Version | Speedy 1.3.0 |
Severity | |
EE Version | 5.3.2 |
Francesco Pensabene
Nov 25, 2020Hello,
just installed speedy, activated static caching.
The problem is that when a page gets cached it changes URL for example :
http://146.59.237.173/dove-siamo/
becomes:
http://146.59.237.173/static/default_site/static/dove-siamo/
this is my .htaccess:
RewriteEngine On
RewriteBase /
#boldminded speedy addon
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{DOCUMENT_ROOT}/static/default_site/static%{REQUEST_URI}/index\.php -f
RewriteRule ^ /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
BoldMinded (Brian)
Nov 25, 2020
Can you share screenshots of your “static” folder, including all sub folders. I want to see if the rest of the directory structure was created correctly.
Also, did you try removing the last 2 htaccess blocks? (everything after # Removes index.php from ExpressionEngine URLs)
Francesco Pensabene
Nov 25, 2020
with this .htaccess I can only browse home page:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{DOCUMENT_ROOT}/static/default_site/static%{REQUEST_URI}/index\.php -f
RewriteRule ^ /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
</IfModule>
Francesco Pensabene
Nov 25, 2020
so with the .htaccess as above I cannot reach any subfolder url -> i need to put index.php
for example:
http://146.59.237.173/contattaci -> gives 404 erro
http://146.59.237.173/index.php/contattaci -> this works
Also my server requires forcing query strings so I usually edit the standard EE .htaccess like so:
RewriteRule ^(.*)$ /index.php?/$1 [L]
BoldMinded (Brian)
Nov 25, 2020
Can you please share screenshots of your static folder with all the files in it so I can see the directory structure? Honestly there isn’t much I can do if he static folder has the correct files. I know that the example htaccess rules in the docs work, and they’re just examples that aren’t officially supported. So if the static directory contains the correct files than there may be something else causing the issue… any number of things can be causing a problem and possibly unrelated to Speedy.
Francesco Pensabene
Nov 25, 2020
I cannot share the directory image right now but I can confirm that the cache files are generated correctly. For me the problem resides in the htaccess rules.
I added the last lines of the standard EE htaccess and now I can browse the website:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{DOCUMENT_ROOT}/static/default_site/static%{REQUEST_URI}/index\.php -f
RewriteRule ^ /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
I don’t have anything strange in place it’s just a new centos/plesk webserver with standard configuration.
BoldMinded (Brian)
Nov 25, 2020
This is kind of what I’m referring to… servers can be wildly different… you may have to experiment with the example htaccess rules to find what works for you. I don’t know if this is correct, b/c I’m not an htaccess expert, but maybe start here:
BoldMinded (Brian)
Nov 25, 2020
This is what I have in my local environment, which works with static files or the static using Redis:
Francesco Pensabene
Nov 25, 2020
Ok,
so the last 3 rules are needed by EE to redirect every url through index.php
Francesco Pensabene
Nov 25, 2020
The last question… is there a way to prune only one page cache? Is it only possible to delete ALL cached files?
BoldMinded (Brian)
Nov 25, 2020
If you click on the magnifying glass you should be able to see and delete individual keys, or re-save the entry and based on your cache busting rules should delete the static file too.
Francesco Pensabene
Nov 26, 2020
Hello Brian,
Now I’m trying to use the fragment caching, I’m working with layouts and I did as stated in the docs i escaped all contents that needs to be replaced in the layout.
But I noticed that in the final template I must escape also the {layout:set name=‘custom_variable’} othervise I ge an error on the template.
is that correct? I couldn’t find anything in the docs
BoldMinded (Brian)
Nov 26, 2020
Can you paste in the full template code you’re using so I can replicate it? You can strip out non relevant html tags or channel:entries tags that aren’t important… basically strip the templates down to the bare minimum to make the issue happen, and paste them here.
Btw it’s a holiday weekend in the states, so my response times may be delayed a bit.
BoldMinded (Brian)
Nov 26, 2020
Are you still using full page static caching?
Francesco Pensabene
Nov 26, 2020
THIS IS THE LAYOUT:
{exp:speedy:fragment key=“layout_generico”}
<!doctype html>
<html class=“no-js” lang=“it”>
<head>
<meta charset=“utf-8”>
<meta http-equiv=“x-ua-compatible” content=“ie=edge”>
<meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
<!—*** FAVICON ***—>
<link rel=“apple-touch-icon” sizes=“180x180” href=”/assets/favicon/apple-touch-icon.png”>
<link rel=“icon” type=“image/png” sizes=“32x32” href=”/assets/favicon/favicon-32x32.png”>
<link rel=“icon” type=“image/png” sizes=“16x16” href=”/assets/favicon/favicon-16x16.png”>
<link rel=“manifest” href=”/assets/favicon/site.webmanifest”>
<link rel=“mask-icon” href=”/assets/favicon/safari-pinned-tab.svg” color=”#043c6b”>
<link rel=“shortcut icon” href=”/assets/favicon/favicon.ico”>
<meta name=“msapplication-TileColor” content=”#ffffff”>
<meta name=“msapplication-config” content=”/assets/favicon/browserconfig.xml”>
<meta name=“theme-color” content=”#ffffff”>
<!—*** STYLES slick css è in app.min.css ***—>
<link rel=“stylesheet” href=”{site_url}assets/foundation-sites/css/app.min.css”>
<link rel=“stylesheet” href=”{site_url}assets/foundation-icons/foundation-icons.css”>
<link rel=“stylesheet” href=”{site_url}assets/fontawesome-free-5.13.1-web/css/all.min.css”>
<!—*** SEO TAGS ***—>
<title>{exp:speedy:escape}{if layout:title}{layout:title}{if:else}WorldBridge{/if}{/exp:speedy:escape}</title>
<meta name=“description” content=”{exp:speedy:escape}{layout:meta_description}{/exp:speedy:escape}”>
{if global:env == ‘stage’}<meta name=“robots” content=“noindex”>{/if}
{if global:env == ‘local’}<meta name=“robots” content=“noindex”>{/if}
<!—*** SOCIAL TAGS ***—>
<meta property=“og:url” content=”{current_url}” />
<meta property=“og:type” content=“article” />
<meta property=“og:title” content=”{exp:speedy:escape}{if layout:title}{layout:title}{if:else}WorldBridge{/if}{/exp:speedy:escape}” />
<meta property=“og:description” content=”{exp:speedy:escape}{layout:meta_description}{/exp:speedy:escape}” />
<meta property=“og:image” content=”{exp:speedy:escape}{if layout:facebook_image}{layout:facebook_image}{if:else}{site_url}assets/img/facebook-default-images/worldbridge-connecting-cultures.jpg{/if}{/exp:speedy:escape}” />
<meta property=“fb:admins” content=“646368982” />
{if global:env == ‘prod’}{var_gtm_head}{/if}
</head>
<body>
{if global:env == ‘prod’}{var_gtm_noscript}{/if}
{par_barra_navigazione}
<!—*** BANDA LOGO ***—>
<div class=“banda_logo_worldbridge grid-x align-center text-center”>
<div class=“small-8 medium-3 large-2 cell”>
_ {site_url}assets/img/logo/logo-worldbridge-rgb.png_
</div>
</div>
{exp:speedy:escape}{layout:contents}{/exp:speedy:escape}
{embed=“_includes/_footer”}
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
{if segment_1 != ‘traduzioni’}
<!—Landbot Chat home page—>
[removed][removed]
[removed]
var myLandbot = new LandbotLivechat({
index: ‘https://landbot.io/u/H-241275-C4326OBIYADELOQQ/index.html’,
});
[removed]
[removed]
// Show a proactive message after 3 seconds
setTimeout(function() {
myLandbot.sendProactive({
“message”: “Ciao, come posso aiutarti?”,
“author”: “Brigitta”,
“avatar”: “https://worldbridge.it/images/antea-50x50.png”,
“extra”: {
“hide_textbox”: true
}
});
}, 3000);
[removed]
{/if}
{if segment_1 == ‘traduzioni’}
<!—Landbot Chat Traduzioni—>
[removed][removed]
[removed]
var myLandbot = new LandbotLivechat({
index: ‘https://landbot.io/u/H-232908-AK2NDG6TU2E684TA/index.html’,
accent: ‘#bc0000’,
});
[removed]
[removed]
// Show a proactive message after 5 seconds
setTimeout(function() {
myLandbot.sendProactive({
“message”: “Ciao, ti servono info sulle traduzioni?”,
“author”: “Brigitta”,
“avatar”: “https://worldbridge.it/images/antea-50x50.png”,
“extra”: {
“hide_textbox”: true
}
});
}, 5000);
[removed]
{/if}
</body>
</html>
{/exp:speedy:fragment}
Francesco Pensabene
Nov 26, 2020
THIS IS ONE “CHILD” TEMPLATE OF THE LAYOUT - If for example I strip off {exp:speedy:escape} from the {layout:set name=‘title’}Corsi di lingua a Milano{/layout:set} I get this printed on the front-end: Corsi di lingua a Milano{/layout:set}
——
{layout=“_layout/_generico”}
{exp:speedy:fragment key=“corsi-milano”}
{exp:speedy:escape}
{layout:set name=‘title’}Corsi di lingua a Milano{/layout:set}
{layout:set name=‘meta_description’}Tutti i corsi di lingua a Milano di WorldBridge{/layout:set}
{/exp:speedy:escape}
<!—*** LISTA CORSI ***—>
<div class=“grid-container”>
<div class=“grid-x grid-padding-x align-center banda_titolo”>
<div class=“cell small-8 medium-8 text-center”>
<h1 class=“beh1 beMainColor”>Corsi di lingue a Milano</h1>
</div>
</div>
<!—*** LISTA CORSI ***—>
<div class=“grid-x grid-margin-x banda”>
{exp:channel:entries channel=“corsi” limit=“30” dynamic=“no” disable=“categories|member_data”}
<div class=“cell small-12 medium-6 large-4 card_academy”>
_ {par_immagine_corso}_ <h4 class=“title_academy beBold”>{title}</h4>_ {meta_description}_ <div class=“cta_academy”>Descrizione del corso <i class=“icona_freccia fas fa-arrow-right”></i></div>_
</div>
{if no_results}
<div class=“cell”>
Non ci sono corsi in questa sezione
</div>
{/if}
{/exp:channel:entries}
</div>
</div>
{/exp:speedy:fragment}
BoldMinded (Brian)
Nov 26, 2020
Can you strip those templates down to _only_ the relevant code to recreate the problem… remove all extra html, channel:entries tags etc. thanks.
BoldMinded (Brian)
Nov 26, 2020
All that extra template code is just noise, I need the simplest template code necessary to recreate the issue before I spend time looking into this.
Francesco Pensabene
Nov 26, 2020
Layout:
Template:
BoldMinded (Brian)
Nov 27, 2020
Francesco, you still haven’t answered the question: Are you still using full page static caching? Fragment caching and static caching are not meant to be used at the same time. They’re 2 completely different types of caching strategies.
Francesco Pensabene
Nov 27, 2020
Hi Brian, sorry, no I’ve disabled it!
BoldMinded (Brian)
Nov 27, 2020
You also don’t have the global=“yes” parameter as noted in the docs: https://docs.boldminded.com/speedy/docs/tags#template-layouts
BoldMinded (Brian)
Nov 27, 2020
I just double checked, and this is what I have that works locally:
layout file:
template file:
This results in the layout:title={layout:title} line rendering correctly.
Francesco Pensabene
Nov 27, 2020
Ok,
to confirm in the template you have to escape the layout:set tags? Is that correct?
BoldMinded (Brian)
Nov 27, 2020
Yep, as noted in the docs.
Francesco Pensabene
Nov 30, 2020
Hi Bryan,
what is this line on your code up?
{embed=“cache/fragment-embed”}
BoldMinded (Brian)
Nov 30, 2020
That embed is just me testing to make sure embeds work with caching and layout variables, which they do.