Author: Derick Rethans (derickr)
Date: 2026-10-06T13:03:21+01:00

Commit: 
https://github.com/php/web-news/commit/10d2e56781349b1c377560b275bf61f3a792d3bb
Raw diff: 
https://github.com/php/web-news/commit/10d2e56781349b1c377560b275bf61f3a792d3bb.diff

Cache RSS feeds for 30 minutes

Changed paths:
  M  group.php
  M  lib/common.php


Diff:

diff --git a/group.php b/group.php
index fee98b1..de571f8 100644
--- a/group.php
+++ b/group.php
@@ -37,9 +37,10 @@
 switch ($format) {
     case 'rss':
         header("Content-type: text/xml");
+        cacheHeader(60 * 30);
         echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";?>
 <rss version="2.0">
- <channel> 
+ <channel>
   <title><?php echo $cleanBaseHost; ?>: <?php echo $cleanGroupHtml?></title>
   <link><?php echo $cleanBaseUrl; ?>/group.php?group=<?php echo 
$cleanGroupUrl?></link>
   <description></description>
@@ -47,6 +48,7 @@
         break;
     case 'rdf':
         header("Content-type: text/xml");
+        cacheHeader(60 * 30);
         echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
         ?>
 <rdf:RDF
diff --git a/lib/common.php b/lib/common.php
index b94e4bb..1c1ef42 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -102,10 +102,15 @@ function posttohost($url, $data)
     return file_get_contents($url, false, $ctx);
 }
 
+function cacheHeader(int $cacheTimeSeconds = 180)
+{
+    header("Cache-Control: public, max-age={$cacheTimeSeconds}");
+}
+
 function head($title = "PHP Mailing Lists (PHP News)", int $cacheTimeSeconds = 
180)
 {
     header("Content-type: text/html; charset=utf-8");
-    header("Cache-Control: public, max-age={$cacheTimeSeconds}");
+    cacheHeader($cacheTimeSeconds);
 
     ?>
 <!doctype html>

Reply via email to