hexo doesn't invalidate cache when you re-generate a single post
Check List
Please check followings before submitting a new issue.
- [ ] I have already read Docs page & Troubleshooting page
- [ ] I have already searched existing issues and they are not help to me
- [ ] I examined error or warning messages and it's difficult to solve
- [ ] Using the latest version of Hexo (run
hexo versionto check) I am using 4.2.0 - [ ] Node.js is higher than 8.6.0
Check
Expected behavior
Edit a post.md file, do hexo generate, when you reload any of the affected pages, they should show the updated changes. In other words, you should be served the contents from /public/.
Actual behavior
For example, if I load my blog's index page after a generate, the most recent post that I am currently editing shows up with no content and With-Inline-Dashes-For-A-Title. I have double checked that the public/index.html folder is updated and has correct content, but a simple wget localhost command produces an index.html page that does not reflect the generated content. The browser also shows what wget receives. So the server is not serving the generated page but rather some kind of in-memory cache.
If I regenerate all pages and restart the server, it works. However this is a lengthy workaround and my site doesn't even have that many pages.
How to reproduce?
- Create a new post
hexo generate- View an affected page (
index.html) using eitherwgeton the server or your web browser.
Environment & Settings
Node.js & npm version
Node v12.16.1
npm 6.14.5
Your site _config.yml (Optional)
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: 'technician by day - engineer at night'
subtitle: ''
description: 'A blog of write-ups and summaries of small technical feats that may serve others.'
keywords: linux, fedora, embedded, arduino, stm32
author: Michael Joya
language: en
timezone: 'America/Vancouver'
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://www.michaeljoya.com/blog
root: /blog/
permalink: :year/:month/:day/:hour/
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks
# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: true # Transform title into titlecase
external_link:
enable: true # Open external links in new tab
field: site # Apply to the whole site
exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: true
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace: ''
wrap: true
hljs: false
# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 0
order_by: -date
# Category & Tag
default_category: uncategorized
category_map:
tag_map:
# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true
# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## Use post's date for updated date unless set in front-matter
use_date_for_updated: false
# Pagination
## Set per_page to 0 to disable pagination
per_page: 0
pagination_dir: page
# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: ''
featured_image:
absolute_path_reference: true
Your theme _config.yml (Optional)
(It's the landscape theme)
# Header
menu:
Home: /
Archives: /archives
rss: /atom.xml
# Content
excerpt_link: Read More
fancybox: true
# Sidebar
sidebar: right
widgets:
- category
- tag
- tagcloud
- archive
- recent_posts
# display widgets at the bottom of index pages (pagination == 2)
index_widgets:
# - category
# - tagcloud
# - archive
# widget behavior
archive_type: 'monthly'
show_count: false
# Miscellaneous
google_analytics:
gauges_analytics:
favicon: /favicon.png
twitter:
google_plus:
fb_admins:
fb_app_id:
Hexo and Plugin version(npm ls --depth 0)
[email protected] /home/blog/hexo
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
Your package.json package.json
{
"name": "hexo-site",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "hexo generate",
"clean": "hexo clean",
"deploy": "hexo deploy",
"server": "hexo server"
},
"hexo": {
"version": "4.2.0"
},
"dependencies": {
"ejs": "^3.1.2",
"hexo": "^4.0.0",
"hexo-asset-link": "^2.0.1",
"hexo-cli-extras": "^1.0.4",
"hexo-featured-image": "^0.4.3",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-category": "^1.0.0",
"hexo-generator-index": "^1.0.0",
"hexo-generator-tag": "^1.0.0",
"hexo-renderer-ejs": "^1.0.0",
"hexo-renderer-marked": "^2.0.0",
"hexo-renderer-stylus": "^1.1.0",
"hexo-server": "^1.0.0",
"video.js": "^7.8.1"
},
"description": "MJ's web site",
"main": "index.js",
"devDependencies": {},
"author": "Michael Joya",
"license": "ISC"
}
Others
Note that putting hexo clean before hexo generate doesn't help. That will delete the /public folder but it doesn't change the discrepancy between the generated file in /public and the one that the server sends as a response.
@mjml
Try adding those lines in _config.yml:
# _config.yml
server:
cache: false
See if it helps.
I had the same problem while writing posts, or working on themes and can confirm disabling the cache in the server setting helps.
same here https://github.com/hexojs/hexo/issues/4991
my new post not indexed after run once hexo clean, and until now still not indexing the posts.
what should i do ? omg
