Home
Support Forums

I need to manually update my website to see its latest version + clear cache and deploy site

Hello Everyone! :slightly_smiling_face:

I searched similar posts but did not find the answer to my problem.

General problem: I need to manually update (F5) my website to see its latest version or I need to clear cache and deploy site in netlify

Running a Hugo site one Netlify (bolsa-inversion.netlify.app) Every time A user visits the site it shows a cached version and requires a refresh to get the latest version. The version shown can be months old depending on the last to the user (maybe browser) visited the site. After one refresh it shows the update version.

I am seeing the correct version in an incognito window.

Any idea? Thank you very much

Last Deploy: Option >> Clear Cahe and Deploy site

2:21:39 PM: Build ready to start
2:21:41 PM: build-image version: 081db65c3e4ce8423fedb40e7689a87de6f84667
2:21:41 PM: build-image tag: v4.3.1
2:21:41 PM: buildbot version: 407a98ff60139d85f01f4f8453046e19d02bbcfd
2:21:41 PM: Building without cache
2:21:41 PM: Starting to prepare the repo for build
2:21:42 PM: No cached dependencies found. Cloning fresh repo
2:21:42 PM: git clone https://github.com/Alrodr/doks-dividendos
2:21:43 PM: Preparing Git Reference refs/heads/main
2:21:44 PM: Parsing package.json dependencies
2:21:44 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'private' in the Netlify UI
2:21:44 PM: Starting build script
2:21:44 PM: Installing dependencies
2:21:44 PM: Python version set to 2.7
2:21:45 PM: Downloading and installing node v16.3.0...
2:21:45 PM: Downloading https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-x64.tar.xz...
2:21:46 PM: Computing checksum with sha256sum
2:21:46 PM: Checksums matched!
2:21:49 PM: Now using node v16.3.0 (npm v7.15.1)
2:21:49 PM: Started restoring cached build plugins
2:21:49 PM: Finished restoring cached build plugins
2:21:49 PM: Attempting ruby version 2.7.2, read from environment
2:21:50 PM: Using ruby version 2.7.2
2:21:51 PM: Using PHP version 8.0
2:21:51 PM: Started restoring cached node modules
2:21:51 PM: Finished restoring cached node modules
2:21:51 PM: Found npm version (7.15.1) that doesn't match expected (7.16.0)Installing npm at version 7.16.0
2:21:55 PM: removed 1 package, changed 29 packages, and audited 256 packages in 3s
2:21:55 PM: 11 packages are looking for funding
2:21:55 PM:   run `npm fund` for details
2:21:55 PM: 3 vulnerabilities (1 moderate, 2 high)
2:21:55 PM: To address all issues, run:
2:21:55 PM:   npm audit fix --force
2:21:55 PM: Run `npm audit` for details.
2:21:55 PM: NPM installed successfully
2:21:55 PM: Installing NPM modules using NPM version 7.16.0
2:22:01 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
2:22:01 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
2:22:10 PM: > @hyas/doks@0.3.4 postinstall
2:22:10 PM: > hugo-installer --version otherDependencies.hugo --extended --destination node_modules/.bin/hugo
2:22:11 PM: Hugo Installer
2:22:11 PM: > Checking for existing binary
2:22:11 PM: > Downloading binary from "https://github.com/gohugoio/hugo/releases/download/v0.88.1/hugo_extended_0.88.1_Linux-64bit.tar.gz"
2:22:11 PM: > Downloading checksum from "https://github.com/gohugoio/hugo/releases/download/v0.88.1/hugo_0.88.1_checksums.txt"
2:22:12 PM: > Verifying binary checksum
2:22:12 PM: > Extracting binary to disk
2:22:12 PM: > Verifying binary health
2:22:13 PM: Hugo is now available in "node_modules/.bin/hugo".
2:22:13 PM: - Version       0.88.1
2:22:13 PM: - Extended      Yes
2:22:13 PM: - OS            linux
2:22:13 PM: - Architecture  x64
2:22:13 PM: hugo v0.88.1-5BC54738+extended linux/amd64 BuildDate=2021-09-04T09:39:19Z VendorInfo=gohugoio
2:22:13 PM: Success!
2:22:13 PM: added 850 packages, and audited 851 packages in 17s
2:22:13 PM: 94 packages are looking for funding
2:22:13 PM:   run `npm fund` for details
2:22:13 PM: found 0 vulnerabilities
2:22:13 PM: NPM modules installed
2:22:13 PM: Started restoring cached go cache
2:22:13 PM: Finished restoring cached go cache
2:22:13 PM: go version go1.16.5 linux/amd64
2:22:13 PM: go version go1.16.5 linux/amd64
2:22:13 PM: Installing missing commands
2:22:13 PM: Verify run directory
2:22:14 PM: ​
2:22:14 PM: ────────────────────────────────────────────────────────────────
2:22:14 PM:   Netlify Build                                                 
2:22:14 PM: ────────────────────────────────────────────────────────────────
2:22:14 PM: ​
2:22:14 PM: ❯ Version
2:22:14 PM:   @netlify/build 18.11.0
2:22:14 PM: ​
2:22:14 PM: ❯ Flags
2:22:14 PM:   baseRelDir: true
2:22:14 PM:   buildId: 6149ce5317702e2a7f6f8ab2
2:22:14 PM:   deployId: 6149ce5317702e2a7f6f8ab4
2:22:14 PM: ​
2:22:14 PM: ❯ Current directory
2:22:14 PM:   /opt/build/repo
2:22:14 PM: ​
2:22:14 PM: ❯ Config file
2:22:14 PM:   /opt/build/repo/netlify.toml
2:22:14 PM: ​
2:22:14 PM: ❯ Context
2:22:14 PM:   production
2:22:14 PM: ​
2:22:14 PM: ────────────────────────────────────────────────────────────────
2:22:14 PM:   1. build.command from netlify.toml                            
2:22:14 PM: ────────────────────────────────────────────────────────────────
2:22:14 PM: ​
2:22:14 PM: $ npm run build
2:22:15 PM: > @hyas/doks@0.3.4 prebuild
2:22:15 PM: > npm run clean
2:22:15 PM: > @hyas/doks@0.3.4 clean
2:22:15 PM: > shx rm -rf public resources
2:22:15 PM: > @hyas/doks@0.3.4 build
2:22:15 PM: > exec-bin node_modules/.bin/hugo/hugo --gc --minify
2:22:15 PM: Start building sites …
2:22:15 PM: hugo v0.88.1-5BC54738+extended linux/amd64 BuildDate=2021-09-04T09:39:19Z VendorInfo=gohugoio
2:22:18 PM:                    | ES
2:22:18 PM: -------------------+-----
2:22:18 PM:   Pages            | 37
2:22:18 PM:   Paginator pages  |  0
2:22:18 PM:   Non-page files   |  4
2:22:18 PM:   Static files     | 94
2:22:18 PM:   Processed images |  0
2:22:18 PM:   Aliases          |  1
2:22:18 PM:   Sitemaps         |  1
2:22:18 PM:   Cleaned          |  0
2:22:18 PM: Total in 2639 ms
2:22:18 PM: ​
2:22:18 PM: (build.command completed in 3.6s)
2:22:18 PM: ​
2:22:18 PM: ────────────────────────────────────────────────────────────────
2:22:18 PM:   2. Functions bundling                                         
2:22:18 PM: ────────────────────────────────────────────────────────────────
2:22:18 PM: ​
2:22:18 PM: Packaging Functions from functions directory:
2:22:18 PM:  - hi-from-lambda.js
2:22:18 PM: ​
2:22:18 PM: ​
2:22:18 PM: (Functions bundling completed in 52ms)
2:22:18 PM: ​
2:22:18 PM: ────────────────────────────────────────────────────────────────
2:22:18 PM:   3. Deploy site                                                
2:22:18 PM: ────────────────────────────────────────────────────────────────
2:22:18 PM: ​
2:22:18 PM: Starting to deploy site from 'public'
2:22:18 PM: Creating deploy tree 
2:22:18 PM: Creating deploy upload records
2:22:18 PM: 0 new files to upload
2:22:18 PM: 0 new functions to upload
2:22:18 PM: Site deploy was successfully initiated
2:22:18 PM: ​
2:22:18 PM: (Deploy site completed in 232ms)
2:22:18 PM: ​
2:22:18 PM: ────────────────────────────────────────────────────────────────
2:22:18 PM:   Netlify Build Complete                                        
2:22:18 PM: ────────────────────────────────────────────────────────────────
2:22:18 PM: ​
2:22:18 PM: (Netlify Build completed in 3.9s)
2:22:19 PM: Starting post processing
2:22:19 PM: Post processing - HTML
2:22:19 PM: Caching artifacts
2:22:19 PM: Started saving node modules
2:22:19 PM: Finished saving node modules
2:22:19 PM: Processing form - contact
2:22:19 PM: Started saving build plugins
2:22:19 PM: Finished saving build plugins
2:22:19 PM: Started saving pip cache
2:22:19 PM: Detected form fields:
2:22:19 PM: Finished saving pip cache
2:22:19 PM: Started saving emacs cask dependencies
2:22:19 PM:  - Name
2:22:19 PM:  - Email
2:22:19 PM: Finished saving emacs cask dependencies
2:22:19 PM:  - Subject
2:22:19 PM:  - Message
2:22:19 PM: Started saving maven dependencies
2:22:19 PM: Finished saving maven dependencies
2:22:19 PM: Started saving boot dependencies
2:22:19 PM: Finished saving boot dependencies
2:22:19 PM: Started saving rust rustup cache
2:22:19 PM: Finished saving rust rustup cache
2:22:19 PM: Started saving go dependencies
2:22:19 PM: Finished saving go dependencies
2:22:19 PM: Post processing - header rules
2:22:19 PM: Post processing - redirect rules
2:22:19 PM: Post processing done
2:22:19 PM: Site is live ✨
2:22:22 PM: Build script success
2:22:49 PM: Finished processing build request in 1m8.083664905s

Hi @Alrodr

This is likely because your browser has cached the page/site locally.

This removes the cache (from previous builds). And as you can see via the build log you shared no new files were deployed because nothing had changed in the build.

The fact that you have tried an incognito window and are seeing the correct thing leads back to the first point about local/browser caching. In the response headers for your site I see

cache-control: public,max-age=31536000

compared to my site where I see

cache-control: public, max-age=0, must-revalidate

My site doesn’t set cached. Yours does.

Have you added custom headers to your site? Or has hugo?

1 Like

First of all, thank you very much for such a complete answer. It is very helpful for inexperienced people like me.

This is likely because your browser has cached the page/site locally.

My users who have the same problem? Will they never be able to see the new updates on each page?

cache-control: public, max-age=0, must-revalidate

I have now set these options, but when i re-deploy, my google chrome updates the new text changes, but does not update a graphic i have made. Maybe that is the problem >> :scream:

:point_down: :point_down: :point_down:
On my pages, I have put graphs to display information.

In order to get them to show up, I had to change my CSP, which is now as follows:

Content-Security-Policy:
default-src β€˜self’ β€˜unsafe-inline’ β€˜unsafe-eval’;
script-src β€˜self’ https://cdn.plot.ly/plotly-latest.min.js β€˜unsafe-inline’ β€˜unsafe-eval’;
connect-src * β€˜unsafe-inline’;
img-src * data: blob: β€˜unsafe-inline’;
frame-src *;
style-src * β€˜unsafe-inline’;
object-src β€˜none’

I’d like it to be safer, but I think that’s another thread.

As you will see, in my head.html header I had to add a script.
I leave below all the code added and schematics:

  • layouts/shortcodes/plotly.html
  • layouts/shortcodes/load-plotly.html
  • layouts/partials/head/head.html
  • content/es/docs/y/x.md
  • static/global_map_counts.json

Thank you for your time!
Sincerily,

Alberto

CODE:
layouts/shortcodes/plotly.html

{{ $json := .Get "json" }}
{{ $height := .Get "height" | default "200px" }}
<div id="{{$json}}" class="plotly" style="height:{{$height}}"></div>
<script>
Plotly.d3.json({{$json}}, function(err, fig) {
    Plotly.plot('{{$json}}', fig.data, fig.layout, {responsive: true});
});
</script>

layouts/shortcodes/load-plotly.html

{{ if not ($.Page.Scratch.Get "plotlyloaded") }}
  {{ $.Page.Scratch.Set "plotlyloaded" 1 }}
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
{{ end }}

layouts/partials/head/head.html

<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  {{ block "head/resource-hints" . }}{{ partial "head/resource-hints.html" . }}{{ end }}
  {{ block "head/script-header" . }}{{ partial "head/script-header.html" . }}{{ end }}
  {{ block "head/stylesheet" . }}{{ partial "head/stylesheet.html" . }}{{ end }}
  {{ block "head/seo" . }}{{ partial "head/seo.html" . }}{{ end }}
  {{ block "head/favicons" . }}{{ partial "head/favicons.html" . }}{{ end }}

 {{- if .Params.Plotly }}
    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
{{- end }}

content/es/docs/y/x.md

---
title: "X"
description: "X"
lead: "x"
date: 2020-10-06T08:48:57+00:00
lastmod: 2020-10-06T08:48:57+00:00
draft: false
images: []
menu:
  docs:
    parent: "y"
weight: 10
toc: true
plotly: true
---

{{< load-plotly >}}
{{< plotly json="/global_map_counts.json" height="450px" >}}

static/global_map_counts.json

{
  "data": [
      {
          "x": [
              "giraffes",
              "orangutans",
              "monkeys"
          ],
          "y": [
              20,
              14,
              23
          ],
          "type": "bar"
      }
  ]
}

If the cache-control header was (at least part of) the reason, when the time is expired and the must-revalidate (which is default Netlify behaviour as explained here) then users (and yourself) should always see the latest version of your site.

I’m not sure what the link between graphs not-/showing on your pages and CSP header is. I fully acknowledge I have no CSP on anything I have done as I haven’t the need for it.

Thank you in any case @coelmay.

The problem is that I am loading java scripts inline. In order to load charts.js inline, you have to give permissions from your CSP. Let’s see if someone can help me.

Thanks :slightly_smiling_face:

Hi @Alrodr

Could you please give a comparison of how the page is looking vs how it should look? We have no means of guessing if the page we’re seeing is correct or not.

Also, I can see some fonts being refused due to CSP no JS. So, I’m assuming you’ve got it correct.

1 Like

The problem was de CSP police.
thank you very much!