-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement cache max age #37
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
package.json (1)
31-31
: LGTM! Consider documenting the cache time parameter.The addition of a 24-hour cache time is a good default for static assets, especially when combined with ETag validation. This will help improve performance for ESP32-served content.
Consider adding a comment in the README about the new
--cachetime
parameter and its impact on browser caching behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (1)
package.json
(2 hunks)
🔇 Additional comments (1)
package.json (1)
57-59
: Verify compatibility with the updated dependencies.The dependency updates look reasonable, with synchronized updates for the TypeScript ESLint packages.
Please verify that the build and tests pass with these updates:
✅ Verification successful
Dependencies are properly synchronized and follow semver guidelines
The package-lock.json is in sync with all three dependency updates, and the TypeScript ESLint packages are correctly updated to the same version. These minor and patch updates should maintain backward compatibility.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the project builds and tests pass with the updated dependencies # Check if package-lock.json is in sync if [ -f "package-lock.json" ]; then if grep -q "\"@types/node\": \"^22.10.5\"" package-lock.json && \ grep -q "\"@typescript-eslint/eslint-plugin\": \"^8.19.1\"" package-lock.json && \ grep -q "\"@typescript-eslint/parser\": \"^8.19.1\"" package-lock.json; then echo "package-lock.json is in sync with package.json" else echo "Warning: package-lock.json might be out of sync with package.json" fi else echo "Warning: package-lock.json not found" fi # Check for any TypeScript errors in the project if command -v tsc &> /dev/null; then echo "Running TypeScript compiler check..." tsc --noEmit else echo "Warning: TypeScript compiler not found in PATH" fiLength of output: 454
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (4)
package.script (1)
1-29
: Document the default cache time value.The script uses a 24-hour (86400 seconds) cache time across all commands. This should be documented to explain the choice of this default value.
Consider adding a comment at the top of the file:
+# Default cache time is set to 24 hours (86400 seconds) +# This provides a good balance between caching benefits and content freshnessAdditionally, consider making the commands DRY-er by extracting common parameters into variables:
#!/bin/bash CACHE_TIME="--cachetime=86400" COMMON_ARGS="-s ./demo/svelte/dist ${CACHE_TIME}"CHANGELOG.md (1)
7-7
: Enhance the changelog entry with more details.While the entry correctly describes the new feature, it could be more helpful with additional details.
Consider expanding the changelog entry:
-- Using the cachetime command line option, you can set whether the browser can cache pages. Together with the ETag switch, you can replace the default no-cache response with a max-age=xy response. +- Added `--cachetime` command line option to control browser caching behavior: + - Default: no-cache (when option is not provided) + - Example: `--cachetime=86400` sets Cache-Control: max-age=86400 (24 hours) + - Works in conjunction with ETag for optimal caching strategyREADME.md (2)
15-16
: Fix markdown formattingRemove the blank line inside the blockquote to comply with markdown best practices.
-> Starting with version v1.7.0, with the cachetime command line option, you can set whether the browser can cache pages -🧰 Tools
🪛 Markdownlint (0.37.0)
16-16: null
Blank line inside blockquote(MD028, no-blanks-blockquote)
181-185
: Improve readability with proper punctuationAdd a comma after "By default" to enhance readability.
-By default (when using the ETag), we send no-cache in the cache-control header +By default, (when using the ETag), we send no-cache in the cache-control header🧰 Tools
🪛 LanguageTool
[uncategorized] ~182-~182: Did you mean: “By default,”?
Context: ...ESP32_ENABLE_ETAG`. ### Cache-control By default (when using the ETag), we send no-cache...(BY_DEFAULT_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
demo/svelte/dist/assets/index-BC9dsMQQ.js
is excluded by!**/dist/**
demo/svelte/dist/assets/index-DiIOlAIu.js
is excluded by!**/dist/**
demo/svelte/dist/favicon.png.gz
is excluded by!**/dist/**
,!**/*.gz
demo/svelte/dist/index.html
is excluded by!**/dist/**
demo/svelte/package-lock.json
is excluded by!**/package-lock.json
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (8)
CHANGELOG.md
(1 hunks)README.md
(3 hunks)demo/esp32/platformio.ini
(1 hunks)demo/svelte/package.json
(2 hunks)package.json
(3 hunks)package.script
(1 hunks)src/commandLine.ts
(2 hunks)src/cppCode.ts
(4 hunks)
✅ Files skipped from review due to trivial changes (1)
- demo/esp32/platformio.ini
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
🧰 Additional context used
🪛 Markdownlint (0.37.0)
README.md
16-16: null
Blank line inside blockquote
(MD028, no-blanks-blockquote)
🪛 LanguageTool
README.md
[uncategorized] ~182-~182: Did you mean: “By default,”?
Context: ...ESP32_ENABLE_ETAG`. ### Cache-control By default (when using the ETag), we send no-cache...
(BY_DEFAULT_COMMA)
🔇 Additional comments (4)
demo/svelte/package.json (2)
27-28
: LGTM! TypeScript ESLint updatesThe updates to
@typescript-eslint
packages are patch version bumps and should be safe.
43-43
: Verify Svelte 5 compatibility with project dependenciesSvelte 5 is currently in beta/alpha stage. Please ensure all project dependencies, especially
flowbite-svelte
and@sveltejs/vite-plugin-svelte
, are compatible with Svelte 5.Run this script to check for potential compatibility issues:
✅ Verification successful
Dependencies are compatible with Svelte 5.16.2
Both
flowbite-svelte
and@sveltejs/vite-plugin-svelte
explicitly support Svelte 5, making the upgrade to version 5.16.2 safe to proceed with.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check compatibility between Svelte 5 and key dependencies # Check flowbite-svelte's package.json for Svelte version requirements curl -s https://registry.npmjs.org/flowbite-svelte/latest | jq -r '.peerDependencies.svelte' # Check vite-plugin-svelte's package.json for Svelte version requirements curl -s https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/latest | jq -r '.peerDependencies.svelte'Length of output: 233
src/cppCode.ts (1)
171-176
: LGTM! Cache-control implementation is thorough and consistent.The cache-control header implementation correctly handles both cases:
- Sets
max-age
when cachetime is provided- Falls back to
no-cache
when cachetime is not setAlso applies to: 358-363, 549-554
README.md (1)
241-241
: LGTM!The new
--cachetime
option is well-documented and follows the existing table format.
"svelte-check": "^4.1.1", | ||
"svelte-preprocess": "^6.0.3", | ||
"tailwindcss": "^3.4.17", | ||
"tslib": "^2.8.1", | ||
"typescript": "^5.7.2", | ||
"vite": "^6.0.5", | ||
"vite": "^6.0.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Update @sveltejs/vite-plugin-svelte to latest version for Vite 6 compatibility
The current version (5.0.3) of @sveltejs/vite-plugin-svelte needs to be upgraded as Vite 6 requires a newer version of this plugin. Other Vite-related dependencies are compatible:
- vite-plugin-tailwind-purgecss: Already supports Vite 6
- @sveltejs/vite-plugin-svelte: Needs upgrade to latest version
🔗 Analysis chain
Verify Vite 6 compatibility and migration requirements
Vite 6 is a recent major release. Please ensure you've reviewed the migration guide and addressed any breaking changes.
Run this script to check for potential compatibility issues:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check compatibility between Vite 6 and key dependencies
# Check vite-plugin-svelte's package.json for Vite version requirements
curl -s https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/latest | jq -r '.peerDependencies.vite'
# Check vite-plugin-tailwind-purgecss's package.json for Vite version requirements
curl -s https://registry.npmjs.org/vite-plugin-tailwind-purgecss/latest | jq -r '.peerDependencies.vite'
Length of output: 242
Script:
#!/bin/bash
# Check for any other Vite-related dependencies and their versions
cat demo/svelte/package.json | jq '.dependencies, .devDependencies' | grep -i vite
Length of output: 192
@@ -10,6 +10,7 @@ interface ICopyFilesArguments { | |||
define: string; | |||
gzip: 'true' | 'false' | 'compiler'; | |||
etag: 'true' | 'false' | 'compiler'; | |||
cachetime: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add validation for the cachetime parameter.
The cachetime
parameter should be validated to ensure it's a non-negative value and within reasonable bounds for max-age cache control.
Consider updating the type definition to include validation:
- cachetime: number;
+ cachetime: {
+ type: (value: number) => number;
+ description: 'max-age cache time in seconds';
+ defaultValue: 0;
+ validate: (value: number) => {
+ if (value < 0) throw new Error('Cache time cannot be negative');
+ if (value > 31536000) throw new Error('Cache time cannot exceed 1 year (31536000 seconds)');
+ return value;
+ }
+ };
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit
New Features
--cachetime
for configuring browser caching behavior.cacheTime
parameter.Chores
Documentation
cachetime
option in the README and CHANGELOG.