feat: add Cache-Control headers for static and PHP files#7
Conversation
WalkthroughThe pull request introduces consistent caching strategies across multiple Nginx configuration files by adding Cache-Control headers. Static files will now be cached for one year, while PHP files, including those in WordPress FastCGI configurations, will be cached for one hour. The changes ensure that responses include appropriate caching directives, optimizing browser and proxy caching behavior. Changes
Sequence DiagramsequenceDiagram
participant Browser
participant Nginx
participant Server
Browser->>Nginx: Request static/PHP file
Nginx->>Server: Fetch file
Server-->>Nginx: Return file with Cache-Control
Nginx-->>Browser: Respond with file and caching headers
Note over Browser: Cache file for specified duration
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
nginx/common/locations.conf (1)
16-16: Validate year-long caching for static files
Serving static assets with "public, max-age=31536000" can dramatically improve performance. However, ensure these files are versioned (e.g., via file hashing in filenames or query parameters). Otherwise, clients might not fetch updated versions after a deploy or modification.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
nginx/common/locations.conf(1 hunks)nginx/common/php.conf(1 hunks)nginx/common/wpfc-php.conf(1 hunks)
🔇 Additional comments (2)
nginx/common/php.conf (1)
13-13: Consider potential caching of user-specific data
Adding the Cache-Control header with "public" may allow proxies or browsers to cache responses that include dynamic or user-specific content. Verify that these PHP endpoints do not expose private or sensitive data that might be served to other users. If such content is possible, consider setting the header to "private" or implementing conditional logic to prevent caching of sensitive pages.
Run the following script to check for any user-specific session or authentication checks in these endpoints that might invalidate public caching:
nginx/common/wpfc-php.conf (1)
45-45: Check for consistency with skip-cache conditions
You have added the same "public, max-age=3600" header for PHP files here. Ensure that the skip-cache conditions above (e.g., for logged-in users, carts, checkout pages) remain properly enforced and do not conflict with a downstream (or proxy) cache. If sensitive pages can get incorrectly cached, you may need to conditionally remove or override this header.
Summary by CodeRabbit
These enhancements improve the performance and efficiency of file delivery by optimizing caching strategies.