Closed (fixed)
Project:
Simple XML sitemap
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Oct 2019 at 22:27 UTC
Updated:
19 Jul 2024 at 13:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
heddnComment #3
heddnComment #4
gbyteWhy would you want to cache it though if its content is fetched entirely from the DB anyways with very little PHP overhead? Have you done performance testing comparing the cached result with the non-cahced result?
See #3001470: Remove caching as now all sitemap content is stored in database.
Comment #5
heddnA couple thoughts on caching. If it is cacheable, then the additional cache layers like redis, memcache, etc can help. Right now I have to rely on the (moderately) slower DB query. Not to mention I can't use HTTP layer caching like 304 Not Modified from Varnish, Fastly, Akamai, CloudFlare, etc.
Comment #6
heddnComment #7
gbyteThanks for the patch. Let's see how much popularity this issue will get.
If what you are doing in
SitemapGeneratorBase::purgeSitemapVariants()is really necessary, it should go intoSitmemapGeneratorBase::invalidateCache()instead and should use the API for getting variants instead of the raw DB query. Maybe something likeSimplesitemapManage::getSitemapVariants()?In
SimplesitemapController::getSitemap, please noteSimplesitemapManager::DEFAULT_SITEMAP_GENERATORis the default sitemap generator and not sitemap variant. There is no default sitemap variant constant, as all variants (sitemap instances) can be deleted. Variant 'default' gets created on install. But generally I don't like that code there and I am sure there is a better way of getting the default sitemap variant somewhere else in your code. You should useSimplesitemap::getVairants(FALSE)to get the currently set variant.Comment #8
heddnI think this addresses your concerns.
\Drupal::service()directly. And if if someone doesn't pass in the variant name, it sounds like we want to flush all the variations.Comment #9
dwwThanks for this issue and patch! I need the same on a site where I'm using simple_sitemap.
A) I marked #3174147: Allow responses to be browser-cached duplicate with this. Please credit @rmontero here, since they worked on a fairly similar fix.
B) The patch in #8 no longer applies cleanly to the 8.x-3.x branch. Simple re-roll here. No interdiff, since the only change is patch context and offsets.
C) I haven't closely reviewed or tested this, but that's coming soon. ;) Stay tuned...
Thanks again,
-Derek
Comment #10
recrit commentedThanks @heddn and @dww! The patch worked for me.
The sitemap.xml is static until it is regenerated so it's a perfect candidate to cache in order to take that load off of the web server.
Comment #11
gbytePartly yes, but don't forget it just gets fetched with a simple SQL select query, so the load shouldn't be substantial.
Comment #12
heddnThis was one of the things that came up in new relic monitoring. So saying this is a simple SQL query... something caused it to bubble to the top of performance optimizations. And there are now 3 different folks who have stumbled on the desire for this feature. Even if you don't see the need for it on your sites, perhaps you could consider that its a fairly simple change (with test coverage) that would benefit others.
Comment #13
gbyte@heddn I was just trying to lower @recrit's expectations regarding the performance gains. I do intend to merge this since the points you made in #5 were convincing. Needs rerolling though, there have been substantial changes in regards to generation performance.
BTW I don't appreciate the notion of me implementing features according to what 'my sites' need. I've spent a considerable amount of time making this module work for the Drupal community which also sometimes means denying feature requests. But you will certainly know that.
Comment #14
bernardm28 commentedCaching this module would be great! Tks for the patch. We hit the threshold two months or so ago, where one can notice a slowdown for it.
Comment #15
fagoI've just noted that sitemaps are not cached. I'd agree that this is a desired feature.
>BTW I don't appreciate the notion of me implementing features according to what 'my sites' need. I've spent a considerable amount of time making this module work for the Drupal community which also sometimes means denying feature requests. But you will certainly know that.
Highly appreciated, thank you for all your hard work!
Comment #16
heddnYes, thank you for your fine work on this module!
Comment #17
gbyte3.x is at feature freeze and 4.x has been deemed good enough for non-api-dependant use cases. Let's get this into 4.x before the stable release!
Comment #19
vasikeRe-rolled the patch for 3.x ... as it seems not working anymore with the latest dev ...
And create new MR https://git.drupalcode.org/issue/simple_sitemap-3090254/-/merge_requests/1
So it can be used for 3.x version ... till upgrade
todo ... 4.x MR ... to be continued
Comment #21
fagothe main hunk
seems to be missing from 4.x ?
Comment #22
ldavidsp commentedSupport for version 4
Comment #23
gbyteComment #25
gngn commentedMy sitemap.xml contains 10,000+ nodes - so I am really interested in caching it.
Comment #26
gbyteThe sitemap is already cached - every sitemap is one record in the database. Thus caching the sitemap via regular caching methods would have little impact. The amount of links has little to do with the retrieval time and more to do with downloading the webpage when you visit /sitemap.xml.
There would be some impact if we implemented this in conjunction with other caching layers, see this comment. I am not opposed to merge this, just waiting for the community to step up as I am working on features that are more important at the moment (in my opinion).
Comment #27
gngn commented@gbyte - ah, thanks.
Comment #28
yonailoI don't know if this patch would fix our issue, but currently we are forced to exclude "/sitemap.xml" from our varnish server in order to get fresh results, would this patch help to clear varnish automatically when the sitemap changes ?
Comment #29
heddnRebase for 4.x again.
Comment #31
gbyteHappy to merge as soon as all tests pass.
Comment #32
heddnLet's see if this fixes tests.
Comment #34
heddnComment #35
gbyte@heddn Thanks.
@WalkingDexter Can you take a close look at the patch in #34?
Comment #38
walkingdexter commentedMade a few changes and committed