Comments (5)
Shlink 4.1.0 has just been released, including the new short-url:delete-expired
console command.
from shlink.
These are some of the other requests for this feature:
Even though I agree this would be definitely a useful feature, it is very tricky to implement, considering the architectural requirements it would have.
For example, Shlink supports (and always will) the classic approach to run and serve PHP apps, using a traditional web server and fast-cgi process manager. In that context, it's very hard to implicitly schedule tasks.
The other supported approach, which is RoadRunner, does have a concept of background jobs that can be programmatically scheduled to be immediately executed, but not at a particular time.
Basically, the logic that takes care of deleting a short URL that has expired, would need to be scheduled somehow, making sure it's deleted only if expired, and take into consideration that the short URL could be edited at any point in time, removing, delaying or forwarding that date.
One could also argue if short URLs which reached maxVisits
should also fall into the "expired short URL" bucket.
Since Shlink does not currently have a way to run code without it being triggered by an incoming request or console command, I can propose an alternative approach. I could add a new console command to Shlink, that would allow you to delete all existing short URLs that can no longer be visited, whether it is because of validUntil
date in the past or maxVisits
has been reached. Then, it's up to you to schedule that command to be run periodically (let's say once per day) using the task scheduler of your choice (let's say cronjobs).
That would be reasonably easy to implement in a backwards-compatible way, and remove all the tricky parts and edge cases away from Shlink.
The command could look like shlink short-url:delete-expired [-f] [--evaluate-max-visits]
.
from shlink.
Thank you for your response. You're right, given the current architectural constraints, a console command is the best solution.
You're also correct about the short URLs that have reached "maxVisits." Those should be deleted as well.
I'd like to propose one more suggestion for discussion: there might be short URLs that shouldn't be deleted even if they have expired. For instance, if they're used for a marketing campaign that gets reactivated periodically.
My suggestion is to introduce a property called "mark-for-deletion" (I couldn't think of a better term at the moment) when creating a short URL. Then, the console command would only consider those that have expired and have "mark-for-deletion" set.
What do you think of this proposal? Do you have a better idea for marking expired short URLs so they won't be deleted?
from shlink.
I think that would be problematic and quickly become confusing for users.
- If you are marking the short URL as non-deletable, people will think deletions happen automatically.
A property that means "it is not auto-deletable, but only applies if you do something else, otherwise this does nothing", will be very hard to reason about.
Instead my thinking is as follows:
- If you don't mind about old expired short URLs, you just ignore the console command, and everything keeps working as it has so far.
- If you use Shlink to create many temporary URLs and want to periodically delete them, then you use the new command. Shlink assumes all "expired" short URLs are safe to delete.
- If there's any exception to the point above and you want to temporarily hide a short URL but without considering it "expired", it is more intuitive to set it a
validSince
date in the future. That would keep it safe from the new command.
from shlink.
As of #2086, this is now implemented
from shlink.
Related Issues (20)
- Set cache lifetime per short url HOT 7
- Allow short URL redirects to be cached by proxy-cache/CDN services
- Failed to import custom slug from Bitly. HOT 5
- Update to RoadRunner 2024
- Can't delete a shortened url HOT 3
- YOURLS Import: INVALID_PORT HOT 3
- Add option to allow all short URLs to be crawlable
- Allow user agents to be customized in robots.txt HOT 5
- Text note to links HOT 8
- Wrong type property for Dynamic Redirection's Docs HOT 1
- Improve general performance around short URLs for instances with a large number HOT 11
- MaxMind GeoLite2 infinite download attempts - problem still exists with 4.0.2 HOT 14
- IP based redirection HOT 1
- `SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT DOCTRINE_2 does not exist` when creating short URL using MariaDB/MySQL HOT 3
- Improve GeoLite2 file downloads when using RoadRunner HOT 1
- Auto generate a url HOT 2
- Add another shlink instances
- Support Japanese charsets HOT 9
- Improve performance when using findIfExists HOT 12
- cpanel
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shlink.