@@ -97,6 +97,29 @@ static void logConsoleError(ScriptExecutionContext* context, const String& messa
9797 context->addConsoleMessage (MessageSource::JS, MessageLevel::Error, message);
9898}
9999
100+ static bool shouldDisableCacheForRequest (URL& url)
101+ {
102+ static Vector<String> s_protocolsNotCached;
103+ static std::once_flag s_onceFlag;
104+ std::call_once (s_onceFlag,
105+ [] {
106+ // The env var contains a comma separated list of protocols that need to disable the cache,
107+ // for example WPE_DISABLE_XHR_RESPONSE_CACHING_FOR_PROTOCOLS="dvb,echo,file"
108+ String s (String::fromLatin1 (std::getenv (" WPE_DISABLE_XHR_RESPONSE_CACHING_FOR_PROTOCOLS" )));
109+ if (!s.isEmpty ()) {
110+ s_protocolsNotCached.appendVector (s.split (' ,' ));
111+ }
112+ });
113+
114+ if (getenv (" WPE_DISABLE_XHR_RESPONSE_CACHING" ))
115+ return true ;
116+
117+ if (s_protocolsNotCached.contains (url.protocol ().toString ()))
118+ return true ;
119+
120+ return false ;
121+ }
122+
100123Ref<XMLHttpRequest> XMLHttpRequest::create (ScriptExecutionContext& context)
101124{
102125 auto xmlHttpRequest = adoptRef (*new XMLHttpRequest (context));
@@ -627,7 +650,7 @@ ExceptionOr<void> XMLHttpRequest::createRequest()
627650 options.filteringPolicy = ResponseFilteringPolicy::Enable;
628651 options.contentEncodingSniffingPolicy = ContentEncodingSniffingPolicy::Disable;
629652
630- if (responseType () == ResponseType::Arraybuffer || getenv ( " WPE_DISABLE_XHR_RESPONSE_CACHING " )) {
653+ if (responseType () == ResponseType::Arraybuffer || shouldDisableCacheForRequest (m_url )) {
631654 options.dataBufferingPolicy = DataBufferingPolicy::DoNotBufferData;
632655 options.cachingPolicy = CachingPolicy::DisallowCaching;
633656 request.setCachePolicy (ResourceRequestCachePolicy::DoNotUseAnyCache);
0 commit comments