Looks like you have to subscribe to an event and manipulate the headers from there. I originally found this answer on how to manipulate headers in D8 here.
This will force a request to the server:
This file will go into your mymodule/src/EventSubscriber folder.
namespace Drupal\mymodule\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class NoCacheSubscriber implements EventSubscriberInterface {
public function RemoveCacheHeaders(FilterResponseEvent $event) {
$response = $event->getResponse();
$response->headers->set('Cache-Control', 'private, must-revalidate, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
}
public static function getSubscribedEvents() {
$events[KernelEvents::RESPONSE][] = array('RemoveCacheHeaders', -10);
return $events;
}
}
Then this will go into the your mymodule folder as mymodule.services.yml
services:
remove_cache_options_subscriber:
class: Drupal\mymodule\EventSubscriber\NoCacheSubscriber
tags:
- { name: event_subscriber }