I have a scheduler which imports articles at a specific time. I can see the content is getting scheduled properly using the scheduled tab but I cannot see the published content. Every morning I need to manually clear the cache to see the scheduled content published otherwise all node goes to 403. Any Idea on this? I tried clearing node tag cache on Scheduler publish event but still didn't worked. Any idea?

Also, I noticed when clearing memcache resolves the issue. I tried to clear the node:nid cache tag on schedule publish event but still didn't worked.
Any idea?

 public function onSchedulePublish(SchedulerEvent $event) {
  /** @var \Drupal\node\Entity\Node $node */
  $node = $event->getNode();
  Cache::invalidateTags($node->getCacheTagsToInvalidate());
  $message = "Node Published and invalidate the cache tags" . $node->id();
  $this->logger->notice($message);
 }

Comments

Dinesh18 created an issue. See original summary.

Dinesh18’s picture

I used CTC clear cache tag module to see which all cache tag can help to clear the necessary cache.
I tried node:nid and node_values and it worked.

jonathan1055’s picture

Category: Bug report » Support request
Priority: Critical » Normal

Hi Dinesh,
In principle Scheduler works properly, there are no cache problems. So this is a normal support request, not a critical bug. There must be some other module or set-up on your site which is doing things with caching. It sounds like you have some ideas for your investigations.

Dinesh18’s picture

I fixed the issue by using the below code

	 * Subscriber Callback for the event.
	 * @param SchedulerEvent $event
	 */
	public function onSchedulePublish(SchedulerEvent $event) {
		/** @var \Drupal\node\Entity\Node $node */
		$node = $event->getNode();
		$tags = ['node:' . $node->id(), 'node_values'];
		Cache::invalidateTags($tags);
		$message = "Node Published and invalidate the cache tags" . $node->id();
		$this->logger->notice($message);
	}
jonathan1055’s picture

Title: Scheduled works fine but some article get published and some not » Scheduler works fine but some articles get published and some not - cache problem
Status: Active » Fixed

That's good to hear. Thanks for posting your result.

Dinesh18’s picture

Thank you @jonathan1055 for the support.

jonathan1055’s picture

Title: Scheduler works fine but some articles get published and some not - cache problem » Scheduler works fine but some articles do not show as published until the cache is cleared

Pleased to help, both here are previously on Slack.
Just altering the title to make it easier for others to search and find.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.