Skip to content

Prevent caching of API routes with dynamic content#922

Merged
Silic0nS0ldier merged 6 commits intodevelopfrom
develop-apiCacheControl
Jan 21, 2019
Merged

Prevent caching of API routes with dynamic content#922
Silic0nS0ldier merged 6 commits intodevelopfrom
develop-apiCacheControl

Conversation

@Silic0nS0ldier
Copy link
Copy Markdown
Member

This is an improvement on #884 to reduce the amount of reused code, and to make it easy to prevent caching of additional routes in a clear manner though the use of middleware.

There may be some routes that need to be excluded, and some added.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 12, 2019

Codecov Report

Merging #922 into develop will increase coverage by <.01%.
The diff coverage is 74.07%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #922      +/-   ##
=============================================
+ Coverage      23.74%   23.74%   +<.01%     
- Complexity      2091     2092       +1     
=============================================
  Files            264      265       +1     
  Lines          13693    13696       +3     
=============================================
+ Hits            3251     3252       +1     
- Misses         10442    10444       +2
Impacted Files Coverage Δ Complexity Δ
...kles/admin/src/Controller/PermissionController.php 0% <0%> (ø) 12 <0> (ø) ⬇️
app/sprinkles/core/src/Bakery/BuildAssets.php 0% <0%> (ø) 18 <0> (ø) ⬇️
app/sprinkles/core/src/Util/NoCache.php 0% <0%> (ø) 1 <1> (?)
.../sprinkles/admin/src/Controller/UserController.php 0% <0%> (ø) 112 <0> (ø) ⬇️
app/sprinkles/admin/routes/groups.php 100% <100%> (ø) 0 <0> (ø) ⬇️
app/sprinkles/admin/routes/permissions.php 100% <100%> (ø) 0 <0> (ø) ⬇️
app/sprinkles/core/src/Util/RawAssetBundles.php 52.63% <100%> (ø) 17 <8> (ø) ⬇️
app/sprinkles/admin/routes/activities.php 100% <100%> (ø) 0 <0> (ø) ⬇️
app/sprinkles/account/routes/routes.php 100% <100%> (ø) 0 <0> (ø) ⬇️
app/sprinkles/admin/routes/admin.php 100% <100%> (ø) 0 <0> (ø) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4822f14...feaf88b. Read the comment docs.

Comment thread app/sprinkles/admin/src/Controller/GroupController.php Outdated
@lcharette
Copy link
Copy Markdown
Member

I haven't looked at all routes that this was applied to, but it looks legit. Middleware class may be better named or with a better namespace to indicate it's a Middleware instead of UserFrosting\Sprinkle\Core\Util\NoCache, but I don't think we have a specific "Middleware" location yet.

@Silic0nS0ldier
Copy link
Copy Markdown
Member Author

Yeah, I tried to match existing patterns, however the only example was AuthGuard. Definitely something to consider in the future though.

@lcharette lcharette added this to the 4.2.0 milestone Jan 21, 2019
@Silic0nS0ldier Silic0nS0ldier merged commit 3795c1e into develop Jan 21, 2019
@Silic0nS0ldier Silic0nS0ldier deleted the develop-apiCacheControl branch January 21, 2019 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants