Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote assets disappear once page is cached #2445

Closed
Tugzrida opened this issue Apr 13, 2019 · 8 comments
Closed

Remote assets disappear once page is cached #2445

Tugzrida opened this issue Apr 13, 2019 · 8 comments

Comments

@Tugzrida
Copy link

Potentially related to previous issues #101 and #770, and branching from #2216, remote assets are(in some cases) only output upon the first page load after a cache clear, completely absent from any subsequent refreshes.

On a clean install of 1.6.3 (plus admin & gantry, also verified before installing gantry), I tested adding FA5 CSS via twig to a single page ({% do assets.addCss('https://use.fontawesome.com/releases/v5.8.1/css/all.css') %}) and via Gantry > Page Settings > Assets to the whole site with different pipelining options selected, the results of which are summarised here:

Pipelining... Twig Gantry 5
off <link> present in first load only <link> always present
on, include externals off <link> present in first load only <link> present in first load only
on, include externals on resource present in pipeline for first load only resource always present in pipeline
@rhukster
Copy link
Member

i'm aware of this particular issue, and will look at it shortly.

@rhukster
Copy link
Member

Ok, please test the fix.

@rhukster rhukster reopened this Apr 13, 2019
@rhukster rhukster added the fixed label Apr 13, 2019
@Tugzrida
Copy link
Author

Works perfectly now when adding via Gantry, however nothing seems to have changed from my table above when doing it via twig. Just to check what I'm doing there: in the Admin panel, I've been enabling twig processing for the target page, then adding the above twig to the top of the page.

@rhukster
Copy link
Member

rhukster commented Apr 14, 2019

I'm not sure you tested with all the changes, because i've tested this (outside of Gantry) and it works perfect in all combinations. here's:

cache:
  enabled: true
  check:
    method: file
assets:
  css_pipeline: true
  css_pipeline_include_externals: false
  css_pipeline_before_excludes: false
  css_minify: true

After several reloads with cache on...

Image 2019-04-13 at 9 56 05 PM

I feel very confident this issue is resolved.

@rhukster
Copy link
Member

btw my Twig:

{% block stylesheets %}
    {% do assets.addCss('https://use.fontawesome.com/releases/v5.8.1/css/all.css') %}
    {% do assets.addCss('theme://css-compiled/spectre'~compress) %}
    {% if theme_var('spectre.exp') %}{% do assets.addCss('theme://css-compiled/spectre-exp'~compress)  %}{% endif %}
    {% if theme_var('spectre.icons') %}{%  do assets.addCss('theme://css-compiled/spectre-icons'~compress) %}{% endif %}
    {% do assets.addCss('theme://css-compiled/theme'~compress) %}
    {% do assets.addCss('theme://css/custom.css') %}
    {% do assets.addCss('theme://css/line-awesome.min.css') %}
{% endblock %}

@Tugzrida
Copy link
Author

I'm still seeing it, here's exactly what I'm doing in an empty folder on my server:
git clone https://github.com/getgrav/grav.git .
bin/grav install
bin/gpm install admin

Then in admin, turn on debugger and edit default home page so it is as follows:

---
title: Home
body_classes: 'title-center title-h1h2'
process:
    markdown: true
    twig: true
---

{% do assets.addCss('https://use.fontawesome.com/releases/v5.8.1/css/all.css') %}

<i class="fab fa-keybase"></i>

# Say Hello to Grav!
...

Then the initial load:
Screen_Shot_2019-04-14_at_14_17_11

And subsequently:
Screen_Shot_2019-04-14_at_14_17_39

Sorry if I'm doing something wrong, I'd normally just do it through gantry, but thought a theme-non-dependent test would be useful.

@rhukster
Copy link
Member

Ok, well there's your problem. You are adding the asset in your content, and the content get's cached and the Twig will get lost. If you want to do it that way you need to set:

never_cache_twig: true

In your frontmatter.

@Tugzrida
Copy link
Author

Ah, thanks, I don't often use twig so I forgot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants